summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-02 09:22:13 (UTC)
committer zautrix <zautrix>2005-07-02 09:22:13 (UTC)
commitcf243d3d9faa7d79eb706f6e70c8d01926e9da89 (patch) (unidiff)
treeccacd0631c1e850ad1d1f7ae5d740d11bcaf35a3 /korganizer
parent58a4e6e5dcc24e2f5c17ef9f0e6879d625b5f764 (diff)
downloadkdepimpi-cf243d3d9faa7d79eb706f6e70c8d01926e9da89.zip
kdepimpi-cf243d3d9faa7d79eb706f6e70c8d01926e9da89.tar.gz
kdepimpi-cf243d3d9faa7d79eb706f6e70c8d01926e9da89.tar.bz2
todo view fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp26
-rw-r--r--korganizer/kotodoview.h1
2 files changed, 17 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 8d354c8..e2966f8 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -559,538 +559,546 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
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 570
571 mItemPopupMenu = new QPopupMenu(this); 571 mItemPopupMenu = new QPopupMenu(this);
572 mItemPopupMenu->insertItem(i18n("Show..."), this, 572 mItemPopupMenu->insertItem(i18n("Show..."), this,
573 SLOT (showTodo())); 573 SLOT (showTodo()));
574 mItemPopupMenu->insertItem(i18n("Edit..."), this, 574 mItemPopupMenu->insertItem(i18n("Edit..."), this,
575 SLOT (editTodo())); 575 SLOT (editTodo()));
576 mItemPopupMenu->insertItem( i18n("Delete"), this, 576 mItemPopupMenu->insertItem( i18n("Delete"), this,
577 SLOT (deleteTodo())); 577 SLOT (deleteTodo()));
578 mItemPopupMenu->insertItem( i18n("Clone..."), this, 578 mItemPopupMenu->insertItem( i18n("Clone..."), this,
579 SLOT (cloneTodo())); 579 SLOT (cloneTodo()));
580 mItemPopupMenu->insertItem( i18n("Move..."), this, 580 mItemPopupMenu->insertItem( i18n("Move..."), this,
581 SLOT (moveTodo())); 581 SLOT (moveTodo()));
582#ifndef DESKTOP_VERSION 582#ifndef DESKTOP_VERSION
583 mItemPopupMenu->insertItem( i18n("Beam..."), this, 583 mItemPopupMenu->insertItem( i18n("Beam..."), this,
584 SLOT (beamTodo())); 584 SLOT (beamTodo()));
585#endif 585#endif
586 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 586 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
587 SLOT (cancelTodo())); 587 SLOT (cancelTodo()));
588 mItemPopupMenu->insertSeparator(); 588 mItemPopupMenu->insertSeparator();
589 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 589 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
590 SLOT (toggleRunningItem())); 590 SLOT (toggleRunningItem()));
591 mItemPopupMenu->insertSeparator(); 591 mItemPopupMenu->insertSeparator();
592 /* 592 /*
593 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 593 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
594 SLOT (newTodo())); 594 SLOT (newTodo()));
595 */ 595 */
596 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 596 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
597 SLOT (newSubTodo())); 597 SLOT (newSubTodo()));
598 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 598 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
599 SLOT (unparentTodo()),0,21); 599 SLOT (unparentTodo()),0,21);
600 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 600 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
601 SLOT (reparentTodo()),0,22); 601 SLOT (reparentTodo()),0,22);
602 mItemPopupMenu->insertSeparator(); 602 mItemPopupMenu->insertSeparator();
603#if 0 603#if 0
604 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 604 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
605 this, SLOT( purgeCompleted() ) ); 605 this, SLOT( purgeCompleted() ) );
606 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 606 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
607 this, SLOT( toggleCompleted() ),0, 33 ); 607 this, SLOT( toggleCompleted() ),0, 33 );
608 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 608 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
609 this, SLOT( toggleQuickTodo() ),0, 34 ); 609 this, SLOT( toggleQuickTodo() ),0, 34 );
610 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 610 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
611 this, SLOT( toggleRunning() ),0, 35 ); 611 this, SLOT( toggleRunning() ),0, 35 );
612 612
613#endif 613#endif
614 mPopupMenu = new QPopupMenu(this); 614 mPopupMenu = new QPopupMenu(this);
615 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 615 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
616 SLOT (newTodo()),0,1); 616 SLOT (newTodo()),0,1);
617 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 617 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
618 this, SLOT(purgeCompleted()),0,2); 618 this, SLOT(purgeCompleted()),0,2);
619 mPopupMenu->insertItem(i18n("Show Completed"), 619 mPopupMenu->insertItem(i18n("Show Completed"),
620 this, SLOT( toggleCompleted() ),0,3 ); 620 this, SLOT( toggleCompleted() ),0,3 );
621 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 621 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
622 this, SLOT( toggleRunning() ),0,5 ); 622 this, SLOT( toggleRunning() ),0,5 );
623 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 623 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
624 this, SLOT( setAllOpen() ),0,6 ); 624 this, SLOT( setAllOpen() ),0,6 );
625 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 625 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
626 this, SLOT( setAllClose() ),0,7 ); 626 this, SLOT( setAllClose() ),0,7 );
627 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 627 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
628 this, SLOT( setAllFlat() ),0,8 ); 628 this, SLOT( setAllFlat() ),0,8 );
629 mPopupMenu->insertSeparator(); 629 mPopupMenu->insertSeparator();
630 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 630 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
631 this, SLOT( toggleQuickTodo() ),0,4 ); 631 this, SLOT( toggleQuickTodo() ),0,4 );
632 mDocPrefs = new DocPrefs( name ); 632 mDocPrefs = new DocPrefs( name );
633 633
634 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 634 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
635 mPopupMenu->setCheckable( true ); 635 mPopupMenu->setCheckable( true );
636 mItemPopupMenu->setCheckable( true ); 636 mItemPopupMenu->setCheckable( true );
637 637
638 638
639 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 639 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
640 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 640 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
641 641
642 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 642 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
643 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 643 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
644 644
645 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 645 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
646 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 646 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
647 647
648 648
649 // Double clicking conflicts with opening/closing the subtree 649 // Double clicking conflicts with opening/closing the subtree
650 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 650 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
651 SLOT( editItem( QListViewItem *) ) ); 651 SLOT( editItem( QListViewItem *) ) );
652 /* 652 /*
653 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 653 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
654 const QPoint &,int ) ), 654 const QPoint &,int ) ),
655 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 655 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
656 */ 656 */
657 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 657 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
658 const QPoint &,int ) ), 658 const QPoint &,int ) ),
659 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 659 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
660 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 660 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
661 SLOT( itemClicked( QListViewItem * ) ) ); 661 SLOT( itemClicked( QListViewItem * ) ) );
662 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 662 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
663 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 663 SLOT( itemDoubleClicked( QListViewItem * ) ) );
664 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 664 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
665 SLOT( updateView() ) ); 665 SLOT( updateView() ) );
666 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 666 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
667 SLOT( todoModified(Todo *, int) ) ); 667 SLOT( todoModified(Todo *, int) ) );
668 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 668 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
669 SLOT( itemStateChanged( QListViewItem * ) ) ); 669 SLOT( itemStateChanged( QListViewItem * ) ) );
670 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 670 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
671 SLOT( itemStateChanged( QListViewItem * ) ) ); 671 SLOT( itemStateChanged( QListViewItem * ) ) );
672 connect( mTodoListView, SIGNAL( paintNeeded() ), 672 connect( mTodoListView, SIGNAL( paintNeeded() ),
673 SLOT( paintNeeded()) ); 673 SLOT( paintNeeded()) );
674 674
675#if 0 675#if 0
676 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 676 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
677 SLOT(selectionChanged(QListViewItem *))); 677 SLOT(selectionChanged(QListViewItem *)));
678 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 678 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
679 SLOT(selectionChanged(QListViewItem *))); 679 SLOT(selectionChanged(QListViewItem *)));
680 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 680 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
681 SLOT(selectionChanged(QListViewItem *))); 681 SLOT(selectionChanged(QListViewItem *)));
682#endif 682#endif
683 683
684 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 684 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
685 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 685 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
686 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 686 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
687 687
688 connect( mTodoListView, SIGNAL(selectionChanged() ), 688 connect( mTodoListView, SIGNAL(selectionChanged() ),
689 SLOT( processSelectionChange() ) ); 689 SLOT( processSelectionChange() ) );
690 connect( mQuickAdd, SIGNAL( returnPressed () ), 690 connect( mQuickAdd, SIGNAL( returnPressed () ),
691 SLOT( addQuickTodo() ) ); 691 SLOT( addQuickTodo() ) );
692 692
693} 693}
694 694
695KOTodoView::~KOTodoView() 695KOTodoView::~KOTodoView()
696{ 696{
697 697
698#if QT_VERSION >= 0x030000 698#if QT_VERSION >= 0x030000
699 699
700#else 700#else
701 delete mKOTodoViewWhatsThis; 701 delete mKOTodoViewWhatsThis;
702#endif 702#endif
703 703
704 delete mDocPrefs; 704 delete mDocPrefs;
705} 705}
706QString KOTodoView::getWhatsThisText(QPoint p) 706QString KOTodoView::getWhatsThisText(QPoint p)
707{ 707{
708 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 708 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
709 if ( item ) 709 if ( item )
710 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 710 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
711 KOPrefs::instance()->mWTshowDetails, 711 KOPrefs::instance()->mWTshowDetails,
712 KOPrefs::instance()->mWTshowCreated, 712 KOPrefs::instance()->mWTshowCreated,
713 KOPrefs::instance()->mWTshowChanged); 713 KOPrefs::instance()->mWTshowChanged);
714 return i18n("That is the todo view" ); 714 return i18n("That is the todo view" );
715 715
716} 716}
717 717
718void KOTodoView::jumpToDate () 718void KOTodoView::jumpToDate ()
719{ 719{
720 // if (mActiveItem) { 720 // if (mActiveItem) {
721// mActiveItem->todo()); 721// mActiveItem->todo());
722// if ( mActiveItem->todo()->hasDueDate() ) 722// if ( mActiveItem->todo()->hasDueDate() )
723// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 723// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
724} 724}
725void KOTodoView::paintNeeded() 725void KOTodoView::paintNeeded()
726{ 726{
727 if ( mPendingUpdateBeforeRepaint ) { 727 if ( mPendingUpdateBeforeRepaint ) {
728 updateView(); 728 updateView();
729 mPendingUpdateBeforeRepaint = false; 729 mPendingUpdateBeforeRepaint = false;
730 } 730 }
731} 731}
732void KOTodoView::paintEvent(QPaintEvent * pevent) 732void KOTodoView::paintEvent(QPaintEvent * pevent)
733{ 733{
734 if ( mPendingUpdateBeforeRepaint ) { 734 if ( mPendingUpdateBeforeRepaint ) {
735 updateView(); 735 updateView();
736 mPendingUpdateBeforeRepaint = false; 736 mPendingUpdateBeforeRepaint = false;
737 } 737 }
738 KOrg::BaseView::paintEvent( pevent); 738 KOrg::BaseView::paintEvent( pevent);
739} 739}
740 740
741void KOTodoView::updateView() 741void KOTodoView::updateView()
742{ 742{
743 pendingSubtodo = 0; 743 pendingSubtodo = 0;
744 if ( mBlockUpdate ) { 744 if ( mBlockUpdate ) {
745 return; 745 return;
746 } 746 }
747 if ( !isVisible() ) { 747 if ( !isVisible() ) {
748 mPendingUpdateBeforeRepaint = true; 748 mPendingUpdateBeforeRepaint = true;
749 return; 749 return;
750 } 750 }
751 storeCurrentItem();
752 //qDebug("KOTodoView::updateView() %x", this); 751 //qDebug("KOTodoView::updateView() %x", this);
753 if ( isFlatDisplay ) { 752 if ( isFlatDisplay ) {
754 displayAllFlat(); 753 displayAllFlat();
755 resetCurrentItem();
756 return; 754 return;
757 } 755 }
756 storeCurrentItem();
758 //qDebug("update "); 757 //qDebug("update ");
759// kdDebug() << "KOTodoView::updateView()" << endl; 758// kdDebug() << "KOTodoView::updateView()" << endl;
760 QFont fo = KOPrefs::instance()->mTodoViewFont; 759 QFont fo = KOPrefs::instance()->mTodoViewFont;
761 760
762 761
763 mTodoListView->clear(); 762 mTodoListView->clear();
764 if ( mName == "todolistsmall" ) { 763 if ( mName == "todolistsmall" ) {
765 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 764 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
766 int ps = fo.pointSize() -2; 765 int ps = fo.pointSize() -2;
767 if ( ps > 12 ) 766 if ( ps > 12 )
768 ps -= 2; 767 ps -= 2;
769 fo.setPointSize( ps ); 768 fo.setPointSize( ps );
770 } 769 }
771 } 770 }
772 771
773 mTodoListView->setFont( fo ); 772 mTodoListView->setFont( fo );
774 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 773 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
775 //mTodoListView->header()->setMaximumHeight(fm.height()); 774 //mTodoListView->header()->setMaximumHeight(fm.height());
776 QPtrList<Todo> todoList = calendar()->todos(); 775 QPtrList<Todo> todoList = calendar()->todos();
777 776
778/* 777/*
779 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 778 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
780 Event *t; 779 Event *t;
781 for(t = todoList.first(); t; t = todoList.next()) { 780 for(t = todoList.first(); t; t = todoList.next()) {
782 kdDebug() << " " << t->getSummary() << endl; 781 kdDebug() << " " << t->getSummary() << endl;
783 782
784 if (t->getRelatedTo()) { 783 if (t->getRelatedTo()) {
785 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 784 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
786 } 785 }
787 786
788 QPtrList<Event> l = t->getRelations(); 787 QPtrList<Event> l = t->getRelations();
789 Event *c; 788 Event *c;
790 for(c=l.first();c;c=l.next()) { 789 for(c=l.first();c;c=l.next()) {
791 kdDebug() << " - relation: " << c->getSummary() << endl; 790 kdDebug() << " - relation: " << c->getSummary() << endl;
792 } 791 }
793 } 792 }
794*/ 793*/
795 794
796 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 795 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
797 // specific order of events. That means that we have to generate parent items 796 // specific order of events. That means that we have to generate parent items
798 // recursively for proper hierarchical display of Todos. 797 // recursively for proper hierarchical display of Todos.
799 mTodoMap.clear(); 798 mTodoMap.clear();
800 Todo *todo; 799 Todo *todo;
801 todo = todoList.first();// todo; todo = todoList.next()) { 800 todo = todoList.first();// todo; todo = todoList.next()) {
802 while ( todo ) { 801 while ( todo ) {
803 bool next = true; 802 bool next = true;
804 // qDebug("todo %s ", todo->summary().latin1()); 803 // qDebug("todo %s ", todo->summary().latin1());
805 Incidence *incidence = todo->relatedTo(); 804 Incidence *incidence = todo->relatedTo();
806 while ( incidence ) { 805 while ( incidence ) {
807 if ( incidence->typeID() == todoID ) { 806 if ( incidence->typeID() == todoID ) {
808 //qDebug("related %s ",incidence->summary().latin1() ); 807 //qDebug("related %s ",incidence->summary().latin1() );
809 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 808 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
810 //qDebug("related not found "); 809 //qDebug("related not found ");
811 todoList.remove( ); 810 todoList.remove( );
812 todo = todoList.current(); 811 todo = todoList.current();
813 next = false; 812 next = false;
814 incidence = 0; 813 incidence = 0;
815 814
816 } else { 815 } else {
817 //qDebug("related found "); 816 //qDebug("related found ");
818 incidence = incidence->relatedTo(); 817 incidence = incidence->relatedTo();
819 } 818 }
820 } else 819 } else
821 incidence = 0; 820 incidence = 0;
822 } 821 }
823 if ( next ) 822 if ( next )
824 todo = todoList.next(); 823 todo = todoList.next();
825 } 824 }
826 825
827 for(todo = todoList.first(); todo; todo = todoList.next()) { 826 for(todo = todoList.first(); todo; todo = todoList.next()) {
828 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 827 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
829 { 828 {
830 insertTodoItem(todo); 829 insertTodoItem(todo);
831 } 830 }
832 } 831 }
833 // Restore opened/closed state 832 // Restore opened/closed state
834 mTodoListView->blockSignals( true ); 833 mTodoListView->blockSignals( true );
835 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 834 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
836 mTodoListView->blockSignals( false ); 835 mTodoListView->blockSignals( false );
837 resetCurrentItem(); 836 resetCurrentItem();
838 processSelectionChange();
839} 837}
840 838
841void KOTodoView::storeCurrentItem() 839void KOTodoView::storeCurrentItem()
842{ 840{
843 mCurItem = 0; 841 mCurItem = 0;
844 mCurItemRootParent = 0; 842 mCurItemRootParent = 0;
845 mCurItemParent = 0; 843 mCurItemParent = 0;
846 mCurItemAbove = 0; 844 mCurItemAbove = 0;
847 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 845 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
848 if (mActiveItem) { 846 if (mActiveItem) {
849 mCurItem = mActiveItem->todo(); 847 mCurItem = mActiveItem->todo();
850 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 848 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
851 if ( activeItemAbove ) 849 if ( activeItemAbove )
852 mCurItemAbove = activeItemAbove->todo(); 850 mCurItemAbove = activeItemAbove->todo();
853 mCurItemRootParent = mCurItem; 851 mCurItemRootParent = mCurItem;
854 mCurItemParent = mCurItemRootParent->relatedTo(); 852 mCurItemParent = mCurItemRootParent->relatedTo();
855 while ( mCurItemRootParent->relatedTo() != 0 ) 853 while ( mCurItemRootParent->relatedTo() != 0 )
856 mCurItemRootParent = mCurItemRootParent->relatedTo(); 854 mCurItemRootParent = mCurItemRootParent->relatedTo();
857 } 855 }
858 mActiveItem = 0; 856 mActiveItem = 0;
859} 857}
860 858
861void KOTodoView::resetCurrentItem() 859void KOTodoView::resetCurrentItem()
862{ 860{
863 mTodoListView->setFocus(); 861 //mTodoListView->setFocus();
864 KOTodoViewItem* foundItem = 0; 862 KOTodoViewItem* foundItem = 0;
865 KOTodoViewItem* foundItemRoot = 0; 863 KOTodoViewItem* foundItemRoot = 0;
866 KOTodoViewItem* foundItemParent = 0; 864 KOTodoViewItem* foundItemParent = 0;
867 KOTodoViewItem* foundItemAbove = 0; 865 KOTodoViewItem* foundItemAbove = 0;
868 if ( mTodoListView->firstChild () ) { 866 if ( mTodoListView->firstChild () ) {
869 if ( mCurItem ) { 867 if ( mCurItem ) {
870 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 868 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
871 while ( item ) { 869 while ( item ) {
872 if ( item->todo() == mCurItem ) { 870 if ( item->todo() == mCurItem ) {
873 foundItem = item; 871 foundItem = item;
874 break; 872 break;
875 } else if ( item->todo() == mCurItemAbove ) { 873 } else if ( item->todo() == mCurItemAbove ) {
876 foundItemAbove = item; 874 foundItemAbove = item;
877 875
878 } 876 }
879 if ( item->todo() == mCurItemRootParent ) { 877 if ( item->todo() == mCurItemRootParent ) {
880 foundItemRoot = item; 878 foundItemRoot = item;
881 } 879 }
882 if ( item->todo() == mCurItemParent ) { 880 if ( item->todo() == mCurItemParent ) {
883 foundItemParent = item; 881 foundItemParent = item;
884 } 882 }
885 item = (KOTodoViewItem*)item->itemBelow(); 883 item = (KOTodoViewItem*)item->itemBelow();
886 } 884 }
887 if ( ! foundItem ) { 885 if ( ! foundItem ) {
888 if ( foundItemParent ) { 886 if ( foundItemParent ) {
889 foundItem = foundItemParent; 887 foundItem = foundItemParent;
890 } else { 888 } else {
891 if ( foundItemRoot ) 889 if ( foundItemRoot )
892 foundItem = foundItemRoot; 890 foundItem = foundItemRoot;
893 else 891 else
894 foundItem = foundItemAbove; 892 foundItem = foundItemAbove;
895 } 893 }
896 } 894 }
897 } 895 }
898 if ( foundItem ) { 896 if ( foundItem ) {
897 mTodoListView->setSelected ( foundItem, true );
899 mTodoListView->setCurrentItem( foundItem ); 898 mTodoListView->setCurrentItem( foundItem );
900 mTodoListView->ensureItemVisible( foundItem ); 899 mTodoListView->ensureItemVisible( foundItem );
901 } else { 900 } else {
902 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 901 if ( mTodoListView->firstChild () ) {
902 mTodoListView->setSelected ( mTodoListView->firstChild (), true );
903 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
904 }
903 } 905 }
904 } 906 }
907 processSelectionChange();
908 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
909}
910void KOTodoView::resetFocusToList()
911{
912 topLevelWidget()->setActiveWindow();
905 mTodoListView->setFocus(); 913 mTodoListView->setFocus();
906} 914}
907//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 915//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
908bool KOTodoView::checkTodo( Todo * todo ) 916bool KOTodoView::checkTodo( Todo * todo )
909{ 917{
910 918
911 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 919 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
912 return false; 920 return false;
913 if ( !todo->isCompleted() ) { 921 if ( !todo->isCompleted() ) {
914 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 922 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
915 return true; 923 return true;
916 } 924 }
917 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 925 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
918 if ( todo->hasStartDate() ) 926 if ( todo->hasStartDate() )
919 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 927 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
920 return false; 928 return false;
921 if ( todo->hasDueDate() ) 929 if ( todo->hasDueDate() )
922 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 930 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
923 return false; 931 return false;
924 } 932 }
925 return true; 933 return true;
926} 934}
927 935
928void KOTodoView::restoreItemState( QListViewItem *item ) 936void KOTodoView::restoreItemState( QListViewItem *item )
929{ 937{
930 pendingSubtodo = 0; 938 pendingSubtodo = 0;
931 while( item ) { 939 while( item ) {
932 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 940 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
933 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 941 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
934 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 942 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
935 item = item->nextSibling(); 943 item = item->nextSibling();
936 } 944 }
937} 945}
938 946
939 947
940QMap<Todo *,KOTodoViewItem *>::ConstIterator 948QMap<Todo *,KOTodoViewItem *>::ConstIterator
941KOTodoView::insertTodoItem(Todo *todo) 949KOTodoView::insertTodoItem(Todo *todo)
942{ 950{
943 951
944 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 952 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
945 // TODO: Check, if dynmaic cast is necessary 953 // TODO: Check, if dynmaic cast is necessary
946 954
947 pendingSubtodo = 0; 955 pendingSubtodo = 0;
948 Incidence *incidence = todo->relatedTo(); 956 Incidence *incidence = todo->relatedTo();
949 while ( incidence && !incidence->calEnabled() ) 957 while ( incidence && !incidence->calEnabled() )
950 incidence = incidence->relatedTo(); 958 incidence = incidence->relatedTo();
951 if (incidence && incidence->typeID() == todoID ) { 959 if (incidence && incidence->typeID() == todoID ) {
952 Todo *relatedTodo = static_cast<Todo *>(incidence); 960 Todo *relatedTodo = static_cast<Todo *>(incidence);
953 961
954 // kdDebug() << " has Related" << endl; 962 // kdDebug() << " has Related" << endl;
955 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 963 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
956 itemIterator = mTodoMap.find(relatedTodo); 964 itemIterator = mTodoMap.find(relatedTodo);
957 if (itemIterator == mTodoMap.end()) { 965 if (itemIterator == mTodoMap.end()) {
958 // kdDebug() << " related not yet in list" << endl; 966 // kdDebug() << " related not yet in list" << endl;
959 itemIterator = insertTodoItem (relatedTodo); 967 itemIterator = insertTodoItem (relatedTodo);
960 } 968 }
961 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 969 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
962 // and one into the map. Sure finding is more easy but why? -zecke 970 // and one into the map. Sure finding is more easy but why? -zecke
963 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 971 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
964 return mTodoMap.insert(todo,todoItem); 972 return mTodoMap.insert(todo,todoItem);
965 } else { 973 } else {
966 // kdDebug() << " no Related" << endl; 974 // kdDebug() << " no Related" << endl;
967 // see above -zecke 975 // see above -zecke
968 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 976 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
969 return mTodoMap.insert(todo,todoItem); 977 return mTodoMap.insert(todo,todoItem);
970 } 978 }
971} 979}
972 980
973 981
974void KOTodoView::updateConfig() 982void KOTodoView::updateConfig()
975{ 983{
976 updateView(); 984 updateView();
977 mTodoListView->repaintContents(); 985 mTodoListView->repaintContents();
978} 986}
979 987
980QPtrList<Incidence> KOTodoView::selectedIncidences() 988QPtrList<Incidence> KOTodoView::selectedIncidences()
981{ 989{
982 QPtrList<Incidence> selected; 990 QPtrList<Incidence> selected;
983 991
984 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 992 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
985// if (!item) item = mActiveItem; 993// if (!item) item = mActiveItem;
986 if (item) selected.append(item->todo()); 994 if (item) selected.append(item->todo());
987 995
988 return selected; 996 return selected;
989} 997}
990 998
991QPtrList<Todo> KOTodoView::selectedTodos() 999QPtrList<Todo> KOTodoView::selectedTodos()
992{ 1000{
993 QPtrList<Todo> selected; 1001 QPtrList<Todo> selected;
994 1002
995 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1003 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
996// if (!item) item = mActiveItem; 1004// if (!item) item = mActiveItem;
997 if (item) selected.append(item->todo()); 1005 if (item) selected.append(item->todo());
998 1006
999 return selected; 1007 return selected;
1000} 1008}
1001 1009
1002void KOTodoView::changeEventDisplay(Event *, int) 1010void KOTodoView::changeEventDisplay(Event *, int)
1003{ 1011{
1004 updateView(); 1012 updateView();
1005} 1013}
1006 1014
1007void KOTodoView::showDates(const QDate &, const QDate &) 1015void KOTodoView::showDates(const QDate &, const QDate &)
1008{ 1016{
1009} 1017}
1010 1018
1011void KOTodoView::showEvents(QPtrList<Event>) 1019void KOTodoView::showEvents(QPtrList<Event>)
1012{ 1020{
1013 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 1021 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
1014} 1022}
1015 1023
1016void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1024void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1017 const QDate &td) 1025 const QDate &td)
1018{ 1026{
1019#ifndef KORG_NOPRINTER 1027#ifndef KORG_NOPRINTER
1020 calPrinter->preview(CalPrinter::Todolist, fd, td); 1028 calPrinter->preview(CalPrinter::Todolist, fd, td);
1021#endif 1029#endif
1022} 1030}
1023 1031
1024void KOTodoView::editItem(QListViewItem *item ) 1032void KOTodoView::editItem(QListViewItem *item )
1025{ 1033{
1026 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 1034 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
1027} 1035}
1028 1036
1029void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 1037void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
1030{ 1038{
1031 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 1039 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
1032} 1040}
1033 1041
1034void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1042void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1035{ 1043{
1036 pendingSubtodo = 0; 1044 pendingSubtodo = 0;
1037 mActiveItem = (KOTodoViewItem *)item; 1045 mActiveItem = (KOTodoViewItem *)item;
1038 if (item) { 1046 if (item) {
1039 switch (column){ 1047 switch (column){
1040 case 1: 1048 case 1:
1041 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1049 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1042 case 2: 1050 case 2:
1043 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1051 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1044 case 3: 1052 case 3:
1045 moveTodo(); 1053 moveTodo();
1046 break; 1054 break;
1047 case 8: 1055 case 8:
1048 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 1056 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
1049 default: 1057 default:
1050 mItemPopupMenu->popup(QCursor::pos()); 1058 mItemPopupMenu->popup(QCursor::pos());
1051 } 1059 }
1052 } else mPopupMenu->popup(QCursor::pos()); 1060 } else mPopupMenu->popup(QCursor::pos());
1053} 1061}
1054void KOTodoView::newTodo() 1062void KOTodoView::newTodo()
1055{ 1063{
1056 emit newTodoSignal(); 1064 emit newTodoSignal();
1057} 1065}
1058 1066
1059void KOTodoView::newSubTodo() 1067void KOTodoView::newSubTodo()
1060{ 1068{
1061 if (mActiveItem) { 1069 if (mActiveItem) {
1062 emit newSubTodoSignal(mActiveItem->todo()); 1070 emit newSubTodoSignal(mActiveItem->todo());
1063 } 1071 }
1064} 1072}
1065void KOTodoView::unparentTodo() 1073void KOTodoView::unparentTodo()
1066{ 1074{
1067 if (mActiveItem) { 1075 if (mActiveItem) {
1068 emit unparentTodoSignal(mActiveItem->todo()); 1076 emit unparentTodoSignal(mActiveItem->todo());
1069 } 1077 }
1070} 1078}
1071 1079
1072void KOTodoView::reparentTodo() 1080void KOTodoView::reparentTodo()
1073{ 1081{
1074 if (mActiveItem) { 1082 if (mActiveItem) {
1075 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1083 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1076 pendingSubtodo = mActiveItem; 1084 pendingSubtodo = mActiveItem;
1077 } 1085 }
1078} 1086}
1079void KOTodoView::editTodo() 1087void KOTodoView::editTodo()
1080{ 1088{
1081 if (mActiveItem) { 1089 if (mActiveItem) {
1082 emit editTodoSignal(mActiveItem->todo()); 1090 emit editTodoSignal(mActiveItem->todo());
1083 } 1091 }
1084} 1092}
1085void KOTodoView::cloneTodo() 1093void KOTodoView::cloneTodo()
1086{ 1094{
1087 if (mActiveItem) { 1095 if (mActiveItem) {
1088 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1096 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1089 } 1097 }
1090} 1098}
1091void KOTodoView::cancelTodo() 1099void KOTodoView::cancelTodo()
1092{ 1100{
1093 if (mActiveItem) { 1101 if (mActiveItem) {
1094 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1102 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1095 } 1103 }
1096} 1104}
@@ -1215,377 +1223,375 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
1215 mActiveItem = (KOTodoViewItem *) item; 1223 mActiveItem = (KOTodoViewItem *) item;
1216 newSubTodo(); 1224 newSubTodo();
1217 return; 1225 return;
1218 } 1226 }
1219 if ( row == 5 || row == 6 || row == 2) { 1227 if ( row == 5 || row == 6 || row == 2) {
1220 mActiveItem = (KOTodoViewItem *) item; 1228 mActiveItem = (KOTodoViewItem *) item;
1221 Todo * t = mActiveItem->todo(); 1229 Todo * t = mActiveItem->todo();
1222 if ( t->isRunning() ) { 1230 if ( t->isRunning() ) {
1223 if ( t->runTime() < 15) { 1231 if ( t->runTime() < 15) {
1224 t->stopRunning(); 1232 t->stopRunning();
1225 mActiveItem->construct(); 1233 mActiveItem->construct();
1226 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1234 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1227 return; 1235 return;
1228 } 1236 }
1229 else 1237 else
1230 toggleRunningItem(); 1238 toggleRunningItem();
1231 return; 1239 return;
1232 } else { 1240 } else {
1233 t->setRunning( true ); 1241 t->setRunning( true );
1234 mActiveItem->construct(); 1242 mActiveItem->construct();
1235 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1243 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1236 return; 1244 return;
1237 } 1245 }
1238 } 1246 }
1239 } 1247 }
1240 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1248 if ( KOPrefs::instance()->mEditOnDoubleClick )
1241 editItem( item ); 1249 editItem( item );
1242 else 1250 else
1243 showItem( item , QPoint(), 0 ); 1251 showItem( item , QPoint(), 0 );
1244} 1252}
1245void KOTodoView::toggleRunningItem() 1253void KOTodoView::toggleRunningItem()
1246{ 1254{
1247 // qDebug("KOTodoView::toggleRunning() "); 1255 // qDebug("KOTodoView::toggleRunning() ");
1248 if ( ! mActiveItem ) 1256 if ( ! mActiveItem )
1249 return; 1257 return;
1250 Todo * t = mActiveItem->todo(); 1258 Todo * t = mActiveItem->todo();
1251 if ( t->isRunning() ) { 1259 if ( t->isRunning() ) {
1252 KOStopTodoPrefs tp ( t, this ); 1260 KOStopTodoPrefs tp ( t, this );
1253 if (QApplication::desktop()->width() <= 800 ){ 1261 if (QApplication::desktop()->width() <= 800 ){
1254 int wid = tp.width(); 1262 int wid = tp.width();
1255 int hei = tp.height(); 1263 int hei = tp.height();
1256 int xx = (QApplication::desktop()->width()-wid)/2; 1264 int xx = (QApplication::desktop()->width()-wid)/2;
1257 int yy = (QApplication::desktop()->height()-hei)/2; 1265 int yy = (QApplication::desktop()->height()-hei)/2;
1258 tp.setGeometry( xx,yy,wid,hei ); 1266 tp.setGeometry( xx,yy,wid,hei );
1259 } 1267 }
1260 tp.exec(); 1268 tp.exec();
1261 mActiveItem->construct(); 1269 mActiveItem->construct();
1262 } else { 1270 } else {
1263 KOStartTodoPrefs tp ( t->summary(), this ); 1271 KOStartTodoPrefs tp ( t->summary(), this );
1264 if (QApplication::desktop()->width() <= 800 ){ 1272 if (QApplication::desktop()->width() <= 800 ){
1265 int wid = tp.width(); 1273 int wid = tp.width();
1266 int hei = tp.height(); 1274 int hei = tp.height();
1267 int xx = (QApplication::desktop()->width()-wid)/2; 1275 int xx = (QApplication::desktop()->width()-wid)/2;
1268 int yy = (QApplication::desktop()->height()-hei)/2; 1276 int yy = (QApplication::desktop()->height()-hei)/2;
1269 tp.setGeometry( xx,yy,wid,hei ); 1277 tp.setGeometry( xx,yy,wid,hei );
1270 } 1278 }
1271 if ( !tp.exec() ) return; 1279 if ( !tp.exec() ) return;
1272 if ( tp.stopAll() ) { 1280 if ( tp.stopAll() ) {
1273 mCalendar->stopAllTodos(); 1281 mCalendar->stopAllTodos();
1274 t->setRunning( true ); 1282 t->setRunning( true );
1275 updateView(); 1283 updateView();
1276 } else { 1284 } else {
1277 t->setRunning( true ); 1285 t->setRunning( true );
1278 mActiveItem->construct(); 1286 mActiveItem->construct();
1279 } 1287 }
1280 } 1288 }
1281} 1289}
1282 1290
1283void KOTodoView::itemClicked(QListViewItem *item) 1291void KOTodoView::itemClicked(QListViewItem *item)
1284{ 1292{
1285 //qDebug("KOTodoView::itemClicked %d", item); 1293 //qDebug("KOTodoView::itemClicked %d", item);
1286 if (!item) { 1294 if (!item) {
1287 if ( pendingSubtodo != 0 ) { 1295 if ( pendingSubtodo != 0 ) {
1288 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1296 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1289 } 1297 }
1290 pendingSubtodo = 0; 1298 pendingSubtodo = 0;
1291 return; 1299 return;
1292 } 1300 }
1293 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1301 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1294 if ( pendingSubtodo != 0 ) { 1302 if ( pendingSubtodo != 0 ) {
1295 bool allowReparent = true; 1303 bool allowReparent = true;
1296 QListViewItem *par = item; 1304 QListViewItem *par = item;
1297 while ( par ) { 1305 while ( par ) {
1298 if ( par == pendingSubtodo ) { 1306 if ( par == pendingSubtodo ) {
1299 allowReparent = false; 1307 allowReparent = false;
1300 break; 1308 break;
1301 } 1309 }
1302 par = par->parent(); 1310 par = par->parent();
1303 } 1311 }
1304 if ( !allowReparent ) { 1312 if ( !allowReparent ) {
1305 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1313 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1306 pendingSubtodo = 0; 1314 pendingSubtodo = 0;
1307 } else { 1315 } else {
1308 Todo* newParent = todoItem->todo(); 1316 Todo* newParent = todoItem->todo();
1309 Todo* newSub = pendingSubtodo->todo(); 1317 Todo* newSub = pendingSubtodo->todo();
1310 pendingSubtodo = 0; 1318 pendingSubtodo = 0;
1311 emit reparentTodoSignal( newParent,newSub ); 1319 emit reparentTodoSignal( newParent,newSub );
1312 return; 1320 return;
1313 } 1321 }
1314 } 1322 }
1315 1323
1316} 1324}
1317 1325
1318void KOTodoView::setDocumentId( const QString &id ) 1326void KOTodoView::setDocumentId( const QString &id )
1319{ 1327{
1320 1328
1321 mDocPrefs->setDoc( id ); 1329 mDocPrefs->setDoc( id );
1322} 1330}
1323 1331
1324void KOTodoView::itemStateChanged( QListViewItem *item ) 1332void KOTodoView::itemStateChanged( QListViewItem *item )
1325{ 1333{
1326 if (!item) return; 1334 if (!item) return;
1327 1335
1328 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1336 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1329 1337
1330// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1338// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1331 1339
1332 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1340 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1333} 1341}
1334 1342
1335void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1343void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1336{ 1344{
1337 mTodoListView->saveLayout(config,group); 1345 mTodoListView->saveLayout(config,group);
1338} 1346}
1339 1347
1340void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1348void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1341{ 1349{
1342 mTodoListView->restoreLayout(config,group); 1350 mTodoListView->restoreLayout(config,group);
1343} 1351}
1344 1352
1345void KOTodoView::processSelectionChange() 1353void KOTodoView::processSelectionChange()
1346{ 1354{
1347// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1355// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1348 1356
1349 KOTodoViewItem *item = 1357 KOTodoViewItem *item =
1350 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1358 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1351 1359
1352 if ( !item ) { 1360 if ( !item ) {
1353 emit incidenceSelected( 0 ); 1361 emit incidenceSelected( 0 );
1354 } else { 1362 } else {
1355 emit incidenceSelected( item->todo() ); 1363 emit incidenceSelected( item->todo() );
1356 } 1364 }
1357} 1365}
1358 1366
1359void KOTodoView::modified(bool b) 1367void KOTodoView::modified(bool b)
1360{ 1368{
1361 emit isModified(b); 1369 emit isModified(b);
1362} 1370}
1363void KOTodoView::setTodoModified( Todo* todo ) 1371void KOTodoView::setTodoModified( Todo* todo )
1364{ 1372{
1365 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1373 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1366} 1374}
1367void KOTodoView::clearSelection() 1375void KOTodoView::clearSelection()
1368{ 1376{
1369 mTodoListView->selectAll( false ); 1377 mTodoListView->selectAll( false );
1370} 1378}
1371void KOTodoView::setAllOpen() 1379void KOTodoView::setAllOpen()
1372{ 1380{
1373 if ( isFlatDisplay ) { 1381 if ( isFlatDisplay ) {
1374 isFlatDisplay = false; 1382 isFlatDisplay = false;
1375 mPopupMenu->setItemChecked( 8,false ); 1383 mPopupMenu->setItemChecked( 8,false );
1376 updateView(); 1384 updateView();
1377 } else { 1385 } else {
1378 storeCurrentItem(); 1386 storeCurrentItem();
1379 } 1387 }
1380 setOpen(mTodoListView->firstChild(), true); 1388 setOpen(mTodoListView->firstChild(), true);
1381 resetCurrentItem(); 1389 resetCurrentItem();
1382} 1390}
1383void KOTodoView::setAllClose() 1391void KOTodoView::setAllClose()
1384{ 1392{
1385 if ( isFlatDisplay ) { 1393 if ( isFlatDisplay ) {
1386 isFlatDisplay = false; 1394 isFlatDisplay = false;
1387 mPopupMenu->setItemChecked( 8,false ); 1395 mPopupMenu->setItemChecked( 8,false );
1388 updateView(); 1396 updateView();
1389 } else { 1397 } else {
1390 storeCurrentItem(); 1398 storeCurrentItem();
1391 } 1399 }
1392 setOpen(mTodoListView->firstChild(), false); 1400 setOpen(mTodoListView->firstChild(), false);
1393 resetCurrentItem(); 1401 resetCurrentItem();
1394} 1402}
1395void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1403void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1396{ 1404{
1397 1405
1398 while ( item ) { 1406 while ( item ) {
1399 setOpen( item->firstChild(), setOpenI ); 1407 setOpen( item->firstChild(), setOpenI );
1400 item->setOpen( setOpenI ); 1408 item->setOpen( setOpenI );
1401 item = item->nextSibling(); 1409 item = item->nextSibling();
1402 } 1410 }
1403} 1411}
1404 1412
1405void KOTodoView::displayAllFlat() 1413void KOTodoView::displayAllFlat()
1406{ 1414{
1415 storeCurrentItem();
1407 pendingSubtodo = 0; 1416 pendingSubtodo = 0;
1408 if ( mBlockUpdate ) { 1417 if ( mBlockUpdate ) {
1409 return; 1418 return;
1410 } 1419 }
1411 mPopupMenu->setItemChecked( 8,true ); 1420 mPopupMenu->setItemChecked( 8,true );
1412 isFlatDisplay = true; 1421 isFlatDisplay = true;
1413 QPtrList<Todo> todoList = calendar()->todos(); 1422 QPtrList<Todo> todoList = calendar()->todos();
1414 mTodoMap.clear(); 1423 mTodoMap.clear();
1415 mTodoListView->clear(); 1424 mTodoListView->clear();
1416 Todo *todo; 1425 Todo *todo;
1417 for(todo = todoList.first(); todo; todo = todoList.next()) { 1426 for(todo = todoList.first(); todo; todo = todoList.next()) {
1418 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1427 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1419 mTodoMap.insert(todo,todoItem); 1428 mTodoMap.insert(todo,todoItem);
1420 } 1429 }
1421 mTodoListView->setFocus(); 1430 resetCurrentItem();
1422 processSelectionChange();
1423} 1431}
1424 1432
1425void KOTodoView::setAllFlat() 1433void KOTodoView::setAllFlat()
1426{ 1434{
1427 if ( isFlatDisplay ) { 1435 if ( isFlatDisplay ) {
1428 isFlatDisplay = false; 1436 isFlatDisplay = false;
1429 mPopupMenu->setItemChecked( 8,false ); 1437 mPopupMenu->setItemChecked( 8,false );
1430 updateView(); 1438 updateView();
1431 return; 1439 return;
1432 } 1440 }
1433 storeCurrentItem();
1434 displayAllFlat(); 1441 displayAllFlat();
1435 resetCurrentItem();
1436} 1442}
1437 1443
1438void KOTodoView::purgeCompleted() 1444void KOTodoView::purgeCompleted()
1439{ 1445{
1440 emit purgeCompletedSignal(); 1446 emit purgeCompletedSignal();
1441 1447
1442} 1448}
1443void KOTodoView::toggleQuickTodo() 1449void KOTodoView::toggleQuickTodo()
1444{ 1450{
1445 if ( mQuickAdd->isVisible() ) { 1451 if ( mQuickAdd->isVisible() ) {
1446 mQuickAdd->hide(); 1452 mQuickAdd->hide();
1447 KOPrefs::instance()->mEnableQuickTodo = false; 1453 KOPrefs::instance()->mEnableQuickTodo = false;
1448 } 1454 }
1449 else { 1455 else {
1450 mQuickAdd->show(); 1456 mQuickAdd->show();
1451 KOPrefs::instance()->mEnableQuickTodo = true; 1457 KOPrefs::instance()->mEnableQuickTodo = true;
1452 } 1458 }
1453 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1459 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1454 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1460 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1455} 1461}
1456 1462
1457void KOTodoView::toggleRunning() 1463void KOTodoView::toggleRunning()
1458{ 1464{
1459 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1465 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1460 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1466 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1461 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1467 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1462 updateView(); 1468 updateView();
1463} 1469}
1464 1470
1465void KOTodoView::toggleCompleted() 1471void KOTodoView::toggleCompleted()
1466{ 1472{
1467 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1473 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1468 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1474 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1469 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1475 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1470 updateView(); 1476 updateView();
1471} 1477}
1472 1478
1473void KOTodoView::addQuickTodo() 1479void KOTodoView::addQuickTodo()
1474{ 1480{
1475 Todo *todo = new Todo(); 1481 Todo *todo = new Todo();
1476 todo->setSummary(mQuickAdd->text()); 1482 todo->setSummary(mQuickAdd->text());
1477 todo->setOrganizer(KOPrefs::instance()->email()); 1483 todo->setOrganizer(KOPrefs::instance()->email());
1478 CalFilter * cf = mCalendar->filter(); 1484 CalFilter * cf = mCalendar->filter();
1479 if ( cf ) { 1485 if ( cf ) {
1480 if ( cf->isEnabled()&& cf->showCategories()) { 1486 if ( cf->isEnabled()&& cf->showCategories()) {
1481 todo->setCategories(cf->categoryList()); 1487 todo->setCategories(cf->categoryList());
1482 } 1488 }
1483 if ( cf->isEnabled() ) 1489 if ( cf->isEnabled() )
1484 todo->setSecrecy( cf->getSecrecy()); 1490 todo->setSecrecy( cf->getSecrecy());
1485 } 1491 }
1486 mCalendar->addTodo(todo); 1492 mCalendar->addTodo(todo);
1487 mQuickAdd->setText(""); 1493 mQuickAdd->setText("");
1488 todoModified (todo, KOGlobals::EVENTADDED ); 1494 todoModified (todo, KOGlobals::EVENTADDED );
1489 updateView(); 1495 updateView();
1490} 1496}
1491 1497
1492void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1498void KOTodoView::keyPressEvent ( QKeyEvent * e )
1493{ 1499{
1494 // e->ignore(); 1500 // e->ignore();
1495 //return; 1501 //return;
1496 //qDebug("KOTodoView::keyPressEvent "); 1502 //qDebug("KOTodoView::keyPressEvent ");
1497 switch ( e->key() ) { 1503 switch ( e->key() ) {
1498 case Qt::Key_Down: 1504 case Qt::Key_Down:
1499 case Qt::Key_Up: 1505 case Qt::Key_Up:
1500 QWidget::keyPressEvent ( e ); 1506 QWidget::keyPressEvent ( e );
1501 break; 1507 break;
1502 1508
1503 case Qt::Key_Q: 1509 case Qt::Key_Q:
1504 toggleQuickTodo(); 1510 toggleQuickTodo();
1505 break; 1511 break;
1506 case Qt::Key_U: 1512 case Qt::Key_U:
1507 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1513 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1508 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1514 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1509 unparentTodo(); 1515 unparentTodo();
1510 e->accept(); 1516 e->accept();
1511 } else 1517 } else
1512 e->ignore(); 1518 e->ignore();
1513 break; 1519 break;
1514 case Qt::Key_S: 1520 case Qt::Key_S:
1515 if ( e->state() == Qt::ControlButton ) { 1521 if ( e->state() == Qt::ControlButton ) {
1516 e->ignore(); 1522 e->ignore();
1517 break; 1523 break;
1518 } 1524 }
1519 if ( e->state() == Qt::ShiftButton ) { 1525 if ( e->state() == Qt::ShiftButton ) {
1520 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1526 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1521 reparentTodo(); 1527 reparentTodo();
1522 e->accept(); 1528 e->accept();
1523 } else 1529 } else
1524 e->ignore(); 1530 e->ignore();
1525 break; 1531 break;
1526 case Qt::Key_P: 1532 case Qt::Key_P:
1527 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1533 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1528 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1534 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1529 if ( pendingSubtodo ) 1535 if ( pendingSubtodo )
1530 itemClicked(mActiveItem); 1536 itemClicked(mActiveItem);
1531 e->accept(); 1537 e->accept();
1532 } else 1538 } else
1533 e->ignore(); 1539 e->ignore();
1534 break; 1540 break;
1535 case Qt::Key_Escape: 1541 case Qt::Key_Escape:
1536 if ( pendingSubtodo ) { 1542 if ( pendingSubtodo ) {
1537 itemClicked(0); 1543 itemClicked(0);
1538 e->accept(); 1544 e->accept();
1539 } else 1545 } else
1540 e->ignore(); 1546 e->ignore();
1541 break; 1547 break;
1542 default: 1548 default:
1543 e->ignore(); 1549 e->ignore();
1544 } 1550 }
1545 1551
1546 if ( true ) { 1552 if ( true ) {
1547 if ( e->key() == Qt::Key_I ) { 1553 if ( e->key() == Qt::Key_I ) {
1548 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1554 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1549 if ( cn ) { 1555 if ( cn ) {
1550 mActiveItem = cn; 1556 mActiveItem = cn;
1551 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1557 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1552 if ( ci ){ 1558 if ( ci ){
1553 showTodo(); 1559 showTodo();
1554 cn = (KOTodoViewItem*)cn->itemBelow(); 1560 cn = (KOTodoViewItem*)cn->itemBelow();
1555 if ( cn ) { 1561 if ( cn ) {
1556 mTodoListView->setCurrentItem ( cn ); 1562 mTodoListView->setCurrentItem ( cn );
1557 mTodoListView->ensureItemVisible ( cn ); 1563 mTodoListView->ensureItemVisible ( cn );
1558 } 1564 }
1559 1565
1560 } 1566 }
1561 } 1567 }
1562 e->accept(); 1568 e->accept();
1563 1569
1564 } 1570 }
1565 1571
1566 } 1572 }
1567 1573
1568} 1574}
1569void KOTodoView::updateTodo( Todo * t, int type ) 1575void KOTodoView::updateTodo( Todo * t, int type )
1570{ 1576{
1571 if ( mBlockUpdate) 1577 if ( mBlockUpdate)
1572 return; 1578 return;
1573 1579
1574 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1580 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1575 itemIterator = mTodoMap.find(t); 1581 itemIterator = mTodoMap.find(t);
1576 if (itemIterator != mTodoMap.end()) { 1582 if (itemIterator != mTodoMap.end()) {
1577 (*itemIterator)->construct(); 1583 (*itemIterator)->construct();
1578 } else { 1584 } else {
1579 if ( type == KOGlobals::EVENTADDED ) { 1585 if ( type == KOGlobals::EVENTADDED ) {
1580 insertTodoItem( t ); 1586 insertTodoItem( t );
1581 } 1587 }
1582 } 1588 }
1583 1589
1584} 1590}
1585 1591
1586void KOTodoView::todoModified(Todo * t , int p ) 1592void KOTodoView::todoModified(Todo * t , int p )
1587{ 1593{
1588 mBlockUpdate = true; 1594 mBlockUpdate = true;
1589 emit todoModifiedSignal ( t, p ); 1595 emit todoModifiedSignal ( t, p );
1590 mBlockUpdate = false; 1596 mBlockUpdate = false;
1591} 1597}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 1b31d0d..9ae7f53 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -35,268 +35,269 @@
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <klistview.h> 38#include <klistview.h>
39 39
40#include <libkcal/calendar.h> 40#include <libkcal/calendar.h>
41#include <libkcal/todo.h> 41#include <libkcal/todo.h>
42 42
43#include <korganizer/baseview.h> 43#include <korganizer/baseview.h>
44 44
45#include "kotodoviewitem.h" 45#include "kotodoviewitem.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49 49
50class QDragEnterEvent; 50class QDragEnterEvent;
51class QDragMoveEvent; 51class QDragMoveEvent;
52class QDragLeaveEvent; 52class QDragLeaveEvent;
53class QDropEvent; 53class QDropEvent;
54class KOTodoViewWhatsThis; 54class KOTodoViewWhatsThis;
55class KDateEdit; 55class KDateEdit;
56class KOTimeEdit; 56class KOTimeEdit;
57 57
58class DocPrefs; 58class DocPrefs;
59 59
60 60
61class KOStopTodoPrefs : public QDialog 61class KOStopTodoPrefs : public QDialog
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 public: 64 public:
65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; 65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
66 66
67 67
68private slots: 68private slots:
69 void doNotSave(); 69 void doNotSave();
70 void accept(); 70 void accept();
71private: 71private:
72 Todo* mTodo; 72 Todo* mTodo;
73 QLineEdit* mComment; 73 QLineEdit* mComment;
74 KDateEdit *sde, *ede; 74 KDateEdit *sde, *ede;
75 KOTimeEdit *ste, *ete; 75 KOTimeEdit *ste, *ete;
76 76
77}; 77};
78 78
79class KOStartTodoPrefs : public QDialog 79class KOStartTodoPrefs : public QDialog
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82 public: 82 public:
83 KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; 83 KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ;
84 84
85 bool stopAll() { return mStopAll; } 85 bool stopAll() { return mStopAll; }
86private slots: 86private slots:
87 void doStop(); 87 void doStop();
88private: 88private:
89 bool mStopAll; 89 bool mStopAll;
90 90
91}; 91};
92 92
93class KOTodoListView : public KListView 93class KOTodoListView : public KListView
94{ 94{
95 Q_OBJECT 95 Q_OBJECT
96 public: 96 public:
97 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 97 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
98 virtual ~KOTodoListView() {} 98 virtual ~KOTodoListView() {}
99 99
100 signals: 100 signals:
101 void paintNeeded(); 101 void paintNeeded();
102 void todoDropped(Todo *, int); 102 void todoDropped(Todo *, int);
103 void double_Clicked(QListViewItem *item); 103 void double_Clicked(QListViewItem *item);
104 void reparentTodoSignal( Todo *,Todo * ); 104 void reparentTodoSignal( Todo *,Todo * );
105 void unparentTodoSignal(Todo *); 105 void unparentTodoSignal(Todo *);
106 void deleteTodo( Todo * ); 106 void deleteTodo( Todo * );
107 protected: 107 protected:
108 void wheelEvent (QWheelEvent *e); 108 void wheelEvent (QWheelEvent *e);
109 void contentsDragEnterEvent(QDragEnterEvent *); 109 void contentsDragEnterEvent(QDragEnterEvent *);
110 void contentsDragMoveEvent(QDragMoveEvent *); 110 void contentsDragMoveEvent(QDragMoveEvent *);
111 void contentsDragLeaveEvent(QDragLeaveEvent *); 111 void contentsDragLeaveEvent(QDragLeaveEvent *);
112 void contentsDropEvent(QDropEvent *); 112 void contentsDropEvent(QDropEvent *);
113 113
114 void contentsMousePressEvent(QMouseEvent *); 114 void contentsMousePressEvent(QMouseEvent *);
115 void contentsMouseMoveEvent(QMouseEvent *); 115 void contentsMouseMoveEvent(QMouseEvent *);
116 void contentsMouseReleaseEvent(QMouseEvent *); 116 void contentsMouseReleaseEvent(QMouseEvent *);
117 void contentsMouseDoubleClickEvent(QMouseEvent *); 117 void contentsMouseDoubleClickEvent(QMouseEvent *);
118 118
119 private: 119 private:
120 void paintEvent(QPaintEvent * pevent); 120 void paintEvent(QPaintEvent * pevent);
121 bool internalDrop; 121 bool internalDrop;
122 QString mName; 122 QString mName;
123 Calendar *mCalendar; 123 Calendar *mCalendar;
124 QPoint mPressPos; 124 QPoint mPressPos;
125 bool mMousePressed; 125 bool mMousePressed;
126 QListViewItem *mOldCurrent; 126 QListViewItem *mOldCurrent;
127 bool mFlagKeyPressed; 127 bool mFlagKeyPressed;
128 void keyPressEvent ( QKeyEvent * ) ; 128 void keyPressEvent ( QKeyEvent * ) ;
129 void keyReleaseEvent ( QKeyEvent * ) ; 129 void keyReleaseEvent ( QKeyEvent * ) ;
130}; 130};
131 131
132 132
133/** 133/**
134 This is the line-edit on top of the todoview for fast addition of new todos 134 This is the line-edit on top of the todoview for fast addition of new todos
135*/ 135*/
136class KOQuickTodo : public QLineEdit 136class KOQuickTodo : public QLineEdit
137{ 137{
138 public: 138 public:
139 KOQuickTodo(QWidget *parent=0); 139 KOQuickTodo(QWidget *parent=0);
140 protected: 140 protected:
141 void focusInEvent(QFocusEvent *ev); 141 void focusInEvent(QFocusEvent *ev);
142 void focusOutEvent(QFocusEvent *ev); 142 void focusOutEvent(QFocusEvent *ev);
143}; 143};
144 144
145 145
146/** 146/**
147 This class provides a multi-column list view of todo events. 147 This class provides a multi-column list view of todo events.
148 148
149 @short multi-column list view of todo events. 149 @short multi-column list view of todo events.
150 @author Cornelius Schumacher <schumacher@kde.org> 150 @author Cornelius Schumacher <schumacher@kde.org>
151*/ 151*/
152class KOTodoView : public KOrg::BaseView 152class KOTodoView : public KOrg::BaseView
153{ 153{
154 Q_OBJECT 154 Q_OBJECT
155 public: 155 public:
156 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 156 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
157 ~KOTodoView(); 157 ~KOTodoView();
158 158
159 QPtrList<Incidence> selectedIncidences(); 159 QPtrList<Incidence> selectedIncidences();
160 QPtrList<Todo> selectedTodos(); 160 QPtrList<Todo> selectedTodos();
161 161
162 DateList selectedDates() 162 DateList selectedDates()
163 {DateList q; 163 {DateList q;
164 return q;} 164 return q;}
165 165
166 /** Return number of shown dates. TodoView does not show dates, */ 166 /** Return number of shown dates. TodoView does not show dates, */
167 int currentDateCount() { return 0; } 167 int currentDateCount() { return 0; }
168 168
169 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 169 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
170 170
171 void setDocumentId( const QString & ); 171 void setDocumentId( const QString & );
172 172
173 void saveLayout(KConfig *config, const QString &group) const; 173 void saveLayout(KConfig *config, const QString &group) const;
174 void restoreLayout(KConfig *config, const QString &group); 174 void restoreLayout(KConfig *config, const QString &group);
175 /** Create a popup menu to set categories */ 175 /** Create a popup menu to set categories */
176 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 176 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
177 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 177 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
178 QString getWhatsThisText(QPoint p); 178 QString getWhatsThisText(QPoint p);
179 void clearList() {mTodoListView->clear(); } 179 void clearList() {mTodoListView->clear(); }
180 180
181 public slots: 181 public slots:
182 void updateView(); 182 void updateView();
183 void updateConfig(); 183 void updateConfig();
184 184
185 void changeEventDisplay(Event *, int); 185 void changeEventDisplay(Event *, int);
186 186
187 void showDates(const QDate &start, const QDate &end); 187 void showDates(const QDate &start, const QDate &end);
188 void showEvents(QPtrList<Event> eventList); 188 void showEvents(QPtrList<Event> eventList);
189 189
190 void clearSelection(); 190 void clearSelection();
191 void jumpToDate (); 191 void jumpToDate ();
192 192
193 void editItem(QListViewItem *item); 193 void editItem(QListViewItem *item);
194 void showItem(QListViewItem *item,const QPoint &,int); 194 void showItem(QListViewItem *item,const QPoint &,int);
195 void popupMenu(QListViewItem *item,const QPoint &,int); 195 void popupMenu(QListViewItem *item,const QPoint &,int);
196 void newTodo(); 196 void newTodo();
197 void newSubTodo(); 197 void newSubTodo();
198 void unparentTodo(); 198 void unparentTodo();
199 void reparentTodo(); 199 void reparentTodo();
200 void showTodo(); 200 void showTodo();
201 void editTodo(); 201 void editTodo();
202 void cloneTodo(); 202 void cloneTodo();
203 void cancelTodo(); 203 void cancelTodo();
204 void moveTodo(); 204 void moveTodo();
205 void beamTodo(); 205 void beamTodo();
206 void deleteTodo(); 206 void deleteTodo();
207 207
208 void setNewPriority(int); 208 void setNewPriority(int);
209 void setNewPercentage(int); 209 void setNewPercentage(int);
210 void changedCategories(int); 210 void changedCategories(int);
211 211
212 void setAllOpen(); 212 void setAllOpen();
213 void setAllClose(); 213 void setAllClose();
214 void setAllFlat(); 214 void setAllFlat();
215 void displayAllFlat(); 215 void displayAllFlat();
216 216
217 void purgeCompleted(); 217 void purgeCompleted();
218 void toggleCompleted(); 218 void toggleCompleted();
219 void toggleRunning(); 219 void toggleRunning();
220 void toggleQuickTodo(); 220 void toggleQuickTodo();
221 void updateTodo( Todo *, int ); 221 void updateTodo( Todo *, int );
222 222
223 void itemClicked(QListViewItem *); 223 void itemClicked(QListViewItem *);
224 void itemStateChanged(QListViewItem *); 224 void itemStateChanged(QListViewItem *);
225 void modified(bool); 225 void modified(bool);
226 void itemDoubleClicked(QListViewItem *item); 226 void itemDoubleClicked(QListViewItem *item);
227 void resetFocusToList();
227 228
228 signals: 229 signals:
229 void newTodoSignal(); 230 void newTodoSignal();
230 void newSubTodoSignal(Todo *); 231 void newSubTodoSignal(Todo *);
231 void unparentTodoSignal(Todo *); 232 void unparentTodoSignal(Todo *);
232 void reparentTodoSignal( Todo *,Todo * ); 233 void reparentTodoSignal( Todo *,Todo * );
233 void showTodoSignal(Todo *); 234 void showTodoSignal(Todo *);
234 235
235 void editTodoSignal(Todo *); 236 void editTodoSignal(Todo *);
236 void deleteTodoSignal(Todo *); 237 void deleteTodoSignal(Todo *);
237 void todoModifiedSignal (Todo *, int); 238 void todoModifiedSignal (Todo *, int);
238 239
239 void isModified(bool); 240 void isModified(bool);
240 void cloneTodoSignal( Incidence * ); 241 void cloneTodoSignal( Incidence * );
241 void cancelTodoSignal( Incidence * ); 242 void cancelTodoSignal( Incidence * );
242 void moveTodoSignal( Incidence * ); 243 void moveTodoSignal( Incidence * );
243 void beamTodoSignal( Incidence * ); 244 void beamTodoSignal( Incidence * );
244 void purgeCompletedSignal(); 245 void purgeCompletedSignal();
245 246
246 protected slots: 247 protected slots:
247 void toggleRunningItem(); 248 void toggleRunningItem();
248 void paintNeeded(); 249 void paintNeeded();
249 void processSelectionChange(); 250 void processSelectionChange();
250 void addQuickTodo(); 251 void addQuickTodo();
251 void setTodoModified( Todo* ); 252 void setTodoModified( Todo* );
252 void todoModified(Todo *, int ); 253 void todoModified(Todo *, int );
253 254
254 private: 255 private:
255 /* 256 /*
256 * the TodoEditor approach is rather unscaling in the long 257 * the TodoEditor approach is rather unscaling in the long
257 * run. 258 * run.
258 * Korganizer keeps it in memory and we need to update 259 * Korganizer keeps it in memory and we need to update
259 * 1. make KOTodoViewItem a QObject again? 260 * 1. make KOTodoViewItem a QObject again?
260 * 2. add a public method for setting one todo modified? 261 * 2. add a public method for setting one todo modified?
261 * 3. add a private method for setting a todo modified + friend here? 262 * 3. add a private method for setting a todo modified + friend here?
262 * -- zecke 2002-07-08 263 * -- zecke 2002-07-08
263 */ 264 */
264 KOTodoViewWhatsThis* mKOTodoViewWhatsThis; 265 KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
265 friend class KOTodoListView; 266 friend class KOTodoListView;
266 void paintEvent(QPaintEvent * pevent); 267 void paintEvent(QPaintEvent * pevent);
267 bool mPendingUpdateBeforeRepaint; 268 bool mPendingUpdateBeforeRepaint;
268 friend class KOTodoViewItem; 269 friend class KOTodoViewItem;
269 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 270 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
270 void restoreItemState( QListViewItem * ); 271 void restoreItemState( QListViewItem * );
271 272
272 bool checkTodo( Todo * ); 273 bool checkTodo( Todo * );
273 bool isFlatDisplay; 274 bool isFlatDisplay;
274 void setOpen( QListViewItem*, bool setOpen); 275 void setOpen( QListViewItem*, bool setOpen);
275 KOTodoListView *mTodoListView; 276 KOTodoListView *mTodoListView;
276 QPopupMenu *mItemPopupMenu; 277 QPopupMenu *mItemPopupMenu;
277 QPopupMenu *mPopupMenu; 278 QPopupMenu *mPopupMenu;
278 QPopupMenu *mPriorityPopupMenu; 279 QPopupMenu *mPriorityPopupMenu;
279 QPopupMenu *mPercentageCompletedPopupMenu; 280 QPopupMenu *mPercentageCompletedPopupMenu;
280 QPopupMenu *mCategoryPopupMenu; 281 QPopupMenu *mCategoryPopupMenu;
281 282
282 QMap<int, int> mPercentage; 283 QMap<int, int> mPercentage;
283 QMap<int, int> mPriority; 284 QMap<int, int> mPriority;
284 QMap<int, QString> mCategory; 285 QMap<int, QString> mCategory;
285 KOTodoViewItem *mActiveItem; 286 KOTodoViewItem *mActiveItem;
286 287
287 QMap<Todo *,KOTodoViewItem *> mTodoMap; 288 QMap<Todo *,KOTodoViewItem *> mTodoMap;
288 QString mName; 289 QString mName;
289 290
290 DocPrefs *mDocPrefs; 291 DocPrefs *mDocPrefs;
291 QString mCurrentDoc; 292 QString mCurrentDoc;
292 KOQuickTodo *mQuickAdd; 293 KOQuickTodo *mQuickAdd;
293 bool mBlockUpdate; 294 bool mBlockUpdate;
294 void keyPressEvent ( QKeyEvent * ) ; 295 void keyPressEvent ( QKeyEvent * ) ;
295 KOTodoViewItem * pendingSubtodo; 296 KOTodoViewItem * pendingSubtodo;
296 DateNavigator* mNavigator; 297 DateNavigator* mNavigator;
297 void storeCurrentItem(); 298 void storeCurrentItem();
298 void resetCurrentItem(); 299 void resetCurrentItem();
299 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; 300 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove;
300}; 301};
301 302
302#endif 303#endif