author | zautrix <zautrix> | 2005-07-06 21:26:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-06 21:26:48 (UTC) |
commit | 630904c92dc014538ff0b08731efb10dcc25426f (patch) (unidiff) | |
tree | fe27e7572546f070aa16445aaaa5084d5f84a965 /korganizer | |
parent | e1731d8790403a079613f291b4ac172d8f04c960 (diff) | |
download | kdepimpi-630904c92dc014538ff0b08731efb10dcc25426f.zip kdepimpi-630904c92dc014538ff0b08731efb10dcc25426f.tar.gz kdepimpi-630904c92dc014538ff0b08731efb10dcc25426f.tar.bz2 |
fixx
-rw-r--r-- | korganizer/kotodoview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index c23a8ee..06d40b1 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -475,1217 +475,1219 @@ void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | |||
475 | 475 | ||
476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
477 | QLineEdit(parent) | 477 | QLineEdit(parent) |
478 | { | 478 | { |
479 | setText(i18n("Click to add a new Todo")); | 479 | setText(i18n("Click to add a new Todo")); |
480 | } | 480 | } |
481 | 481 | ||
482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
483 | { | 483 | { |
484 | if ( text()==i18n("Click to add a new Todo") ) | 484 | if ( text()==i18n("Click to add a new Todo") ) |
485 | setText(""); | 485 | setText(""); |
486 | QLineEdit::focusInEvent(ev); | 486 | QLineEdit::focusInEvent(ev); |
487 | } | 487 | } |
488 | 488 | ||
489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
490 | { | 490 | { |
491 | setText(i18n("Click to add a new Todo")); | 491 | setText(i18n("Click to add a new Todo")); |
492 | QLineEdit::focusOutEvent(ev); | 492 | QLineEdit::focusOutEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | ///////////////////////////////////////////////////////////////////////////// | 495 | ///////////////////////////////////////////////////////////////////////////// |
496 | 496 | ||
497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
498 | KOrg::BaseView(calendar,parent,name) | 498 | KOrg::BaseView(calendar,parent,name) |
499 | { | 499 | { |
500 | mCategoryPopupMenu = 0; | 500 | mCategoryPopupMenu = 0; |
501 | mPendingUpdateBeforeRepaint = false; | 501 | mPendingUpdateBeforeRepaint = false; |
502 | isFlatDisplay = false; | 502 | isFlatDisplay = false; |
503 | mNavigator = 0; | 503 | mNavigator = 0; |
504 | QBoxLayout *topLayout = new QVBoxLayout(this); | 504 | QBoxLayout *topLayout = new QVBoxLayout(this); |
505 | mName = QString ( name ); | 505 | mName = QString ( name ); |
506 | mBlockUpdate = false; | 506 | mBlockUpdate = false; |
507 | mQuickBar = new QWidget( this ); | 507 | mQuickBar = new QWidget( this ); |
508 | topLayout->addWidget(mQuickBar); | 508 | topLayout->addWidget(mQuickBar); |
509 | 509 | ||
510 | mQuickAdd = new KOQuickTodo(mQuickBar); | 510 | mQuickAdd = new KOQuickTodo(mQuickBar); |
511 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 511 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
512 | quickLayout->addWidget( mQuickAdd ); | 512 | quickLayout->addWidget( mQuickAdd ); |
513 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 513 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
514 | int fixwid = flat->sizeHint().height(); | 514 | int fixwid = flat->sizeHint().height(); |
515 | if ( QApplication::desktop()->width() > 320 ) | 515 | if ( QApplication::desktop()->width() > 320 ) |
516 | fixwid *= 2; | 516 | fixwid *= 2; |
517 | flat->setFixedWidth( fixwid ); | 517 | flat->setFixedWidth( fixwid ); |
518 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 518 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
519 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 519 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
520 | allopen->setFixedWidth( fixwid ); | 520 | allopen->setFixedWidth( fixwid ); |
521 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 521 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
522 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 522 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
523 | allclose->setFixedWidth( fixwid ); | 523 | allclose->setFixedWidth( fixwid ); |
524 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 524 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
525 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 525 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
526 | s_done->setFixedWidth( fixwid ); | 526 | s_done->setFixedWidth( fixwid ); |
527 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 527 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
528 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 528 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
529 | s_run->setFixedWidth( fixwid ); | 529 | s_run->setFixedWidth( fixwid ); |
530 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 530 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
531 | 531 | ||
532 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 532 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
533 | mNewSubBut->setFixedWidth( fixwid*3/2 ); | 533 | mNewSubBut->setFixedWidth( fixwid*3/2 ); |
534 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 534 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
535 | mNewSubBut->setEnabled( false ); | 535 | mNewSubBut->setEnabled( false ); |
536 | quickLayout->addWidget( mNewSubBut ); | 536 | quickLayout->addWidget( mNewSubBut ); |
537 | quickLayout->addWidget( s_done ); | 537 | quickLayout->addWidget( s_done ); |
538 | quickLayout->addWidget( s_run ); | 538 | quickLayout->addWidget( s_run ); |
539 | 539 | ||
540 | quickLayout->addWidget( allopen ); | 540 | quickLayout->addWidget( allopen ); |
541 | quickLayout->addWidget( allclose ); | 541 | quickLayout->addWidget( allclose ); |
542 | quickLayout->addWidget( flat ); | 542 | quickLayout->addWidget( flat ); |
543 | 543 | ||
544 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 544 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
545 | 545 | ||
546 | mTodoListView = new KOTodoListView(calendar,this, name ); | 546 | mTodoListView = new KOTodoListView(calendar,this, name ); |
547 | topLayout->addWidget(mTodoListView); | 547 | topLayout->addWidget(mTodoListView); |
548 | //mTodoListView->header()->setMaximumHeight(30); | 548 | //mTodoListView->header()->setMaximumHeight(30); |
549 | mTodoListView->setRootIsDecorated(true); | 549 | mTodoListView->setRootIsDecorated(true); |
550 | mTodoListView->setAllColumnsShowFocus(true); | 550 | mTodoListView->setAllColumnsShowFocus(true); |
551 | 551 | ||
552 | mTodoListView->setShowSortIndicator(true); | 552 | mTodoListView->setShowSortIndicator(true); |
553 | 553 | ||
554 | mTodoListView->addColumn(i18n("Todo")); | 554 | mTodoListView->addColumn(i18n("Todo")); |
555 | mTodoListView->addColumn(i18n("Prio")); | 555 | mTodoListView->addColumn(i18n("Prio")); |
556 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 556 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
557 | mTodoListView->addColumn(i18n("Complete")); | 557 | mTodoListView->addColumn(i18n("Complete")); |
558 | mTodoListView->setColumnAlignment(2,AlignCenter); | 558 | mTodoListView->setColumnAlignment(2,AlignCenter); |
559 | 559 | ||
560 | mTodoListView->addColumn(i18n("Due Date")); | 560 | mTodoListView->addColumn(i18n("Due Date")); |
561 | mTodoListView->setColumnAlignment(3,AlignLeft); | 561 | mTodoListView->setColumnAlignment(3,AlignLeft); |
562 | mTodoListView->addColumn(i18n("Due Time")); | 562 | mTodoListView->addColumn(i18n("Due Time")); |
563 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 563 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
564 | 564 | ||
565 | mTodoListView->addColumn(i18n("Start Date")); | 565 | mTodoListView->addColumn(i18n("Start Date")); |
566 | mTodoListView->setColumnAlignment(5,AlignLeft); | 566 | mTodoListView->setColumnAlignment(5,AlignLeft); |
567 | mTodoListView->addColumn(i18n("Start Time")); | 567 | mTodoListView->addColumn(i18n("Start Time")); |
568 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 568 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
569 | 569 | ||
570 | mTodoListView->addColumn(i18n("Cancelled")); | 570 | mTodoListView->addColumn(i18n("Cancelled")); |
571 | mTodoListView->addColumn(i18n("Categories")); | 571 | mTodoListView->addColumn(i18n("Categories")); |
572 | mTodoListView->addColumn(i18n("Calendar")); | 572 | mTodoListView->addColumn(i18n("Calendar")); |
573 | #if 0 | 573 | #if 0 |
574 | mTodoListView->addColumn(i18n("Sort Id")); | 574 | mTodoListView->addColumn(i18n("Sort Id")); |
575 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 575 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | mTodoListView->setMinimumHeight( 60 ); | 578 | mTodoListView->setMinimumHeight( 60 ); |
579 | mTodoListView->setItemsRenameable( true ); | 579 | mTodoListView->setItemsRenameable( true ); |
580 | mTodoListView->setRenameable( 0 ); | 580 | mTodoListView->setRenameable( 0 ); |
581 | mTodoListView->setColumnWidth( 0, 120 ); | 581 | mTodoListView->setColumnWidth( 0, 120 ); |
582 | int iii = 0; | 582 | int iii = 0; |
583 | for ( iii = 0; iii< 10 ; ++iii ) | 583 | for ( iii = 0; iii< 10 ; ++iii ) |
584 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 584 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
585 | 585 | ||
586 | 586 | ||
587 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 587 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
588 | 588 | ||
589 | mPriorityPopupMenu = new QPopupMenu(this); | 589 | mPriorityPopupMenu = new QPopupMenu(this); |
590 | for (int i = 1; i <= 5; i++) { | 590 | for (int i = 1; i <= 5; i++) { |
591 | QString label = QString ("%1").arg (i); | 591 | QString label = QString ("%1").arg (i); |
592 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 592 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
593 | } | 593 | } |
594 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 594 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
595 | 595 | ||
596 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 596 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
597 | for (int i = 0; i <= 100; i+=20) { | 597 | for (int i = 0; i <= 100; i+=20) { |
598 | QString label = QString ("%1 %").arg (i); | 598 | QString label = QString ("%1 %").arg (i); |
599 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 599 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
600 | } | 600 | } |
601 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 601 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
602 | 602 | ||
603 | 603 | ||
604 | mCategoryPopupMenu = new QPopupMenu (this); | 604 | mCategoryPopupMenu = new QPopupMenu (this); |
605 | mCategoryPopupMenu->setCheckable (true); | 605 | mCategoryPopupMenu->setCheckable (true); |
606 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 606 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
607 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 607 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
608 | 608 | ||
609 | mCalPopupMenu = new QPopupMenu (this); | 609 | mCalPopupMenu = new QPopupMenu (this); |
610 | mCalPopupMenu->setCheckable (true); | 610 | mCalPopupMenu->setCheckable (true); |
611 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 611 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
612 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 612 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
613 | 613 | ||
614 | 614 | ||
615 | 615 | ||
616 | 616 | ||
617 | mItemPopupMenu = new QPopupMenu(this); | 617 | mItemPopupMenu = new QPopupMenu(this); |
618 | mItemPopupMenu->insertItem(i18n("Show"), this, | 618 | mItemPopupMenu->insertItem(i18n("Show"), this, |
619 | SLOT (showTodo())); | 619 | SLOT (showTodo())); |
620 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 620 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
621 | SLOT (editTodo())); | 621 | SLOT (editTodo())); |
622 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 622 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
623 | SLOT (deleteTodo())); | 623 | SLOT (deleteTodo())); |
624 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 624 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
625 | SLOT (cloneTodo())); | 625 | SLOT (cloneTodo())); |
626 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 626 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
627 | SLOT (moveTodo())); | 627 | SLOT (moveTodo())); |
628 | #ifndef DESKTOP_VERSION | 628 | #ifndef DESKTOP_VERSION |
629 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 629 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
630 | SLOT (beamTodo())); | 630 | SLOT (beamTodo())); |
631 | #endif | 631 | #endif |
632 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 632 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
633 | SLOT (cancelTodo())); | 633 | SLOT (cancelTodo())); |
634 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 634 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
635 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 635 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
636 | mItemPopupMenu->insertSeparator(); | 636 | mItemPopupMenu->insertSeparator(); |
637 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 637 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
638 | SLOT (toggleRunningItem())); | 638 | SLOT (toggleRunningItem())); |
639 | mItemPopupMenu->insertSeparator(); | 639 | mItemPopupMenu->insertSeparator(); |
640 | /* | 640 | /* |
641 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 641 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
642 | SLOT (newTodo())); | 642 | SLOT (newTodo())); |
643 | */ | 643 | */ |
644 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 644 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
645 | SLOT (newSubTodo())); | 645 | SLOT (newSubTodo())); |
646 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 646 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
647 | SLOT (unparentTodo()),0,21); | 647 | SLOT (unparentTodo()),0,21); |
648 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 648 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
649 | SLOT (reparentTodo()),0,22); | 649 | SLOT (reparentTodo()),0,22); |
650 | mItemPopupMenu->insertSeparator(); | 650 | mItemPopupMenu->insertSeparator(); |
651 | #if 0 | 651 | #if 0 |
652 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 652 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
653 | this, SLOT( purgeCompleted() ) ); | 653 | this, SLOT( purgeCompleted() ) ); |
654 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 654 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
655 | this, SLOT( toggleCompleted() ),0, 33 ); | 655 | this, SLOT( toggleCompleted() ),0, 33 ); |
656 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 656 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
657 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 657 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
658 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 658 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
659 | this, SLOT( toggleRunning() ),0, 35 ); | 659 | this, SLOT( toggleRunning() ),0, 35 ); |
660 | 660 | ||
661 | #endif | 661 | #endif |
662 | mPopupMenu = new QPopupMenu(this); | 662 | mPopupMenu = new QPopupMenu(this); |
663 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 663 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
664 | SLOT (newTodo()),0,1); | 664 | SLOT (newTodo()),0,1); |
665 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 665 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
666 | this, SLOT(purgeCompleted()),0,2); | 666 | this, SLOT(purgeCompleted()),0,2); |
667 | mPopupMenu->insertItem(i18n("Show Completed"), | 667 | mPopupMenu->insertItem(i18n("Show Completed"), |
668 | this, SLOT( toggleCompleted() ),0,3 ); | 668 | this, SLOT( toggleCompleted() ),0,3 ); |
669 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 669 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
670 | this, SLOT( toggleRunning() ),0,5 ); | 670 | this, SLOT( toggleRunning() ),0,5 ); |
671 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 671 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
672 | this, SLOT( setAllOpen() ),0,6 ); | 672 | this, SLOT( setAllOpen() ),0,6 ); |
673 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 673 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
674 | this, SLOT( setAllClose() ),0,7 ); | 674 | this, SLOT( setAllClose() ),0,7 ); |
675 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 675 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
676 | this, SLOT( setAllFlat() ),0,8 ); | 676 | this, SLOT( setAllFlat() ),0,8 ); |
677 | mPopupMenu->insertSeparator(); | 677 | mPopupMenu->insertSeparator(); |
678 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 678 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
679 | this, SLOT( toggleQuickTodo() ),0,4 ); | 679 | this, SLOT( toggleQuickTodo() ),0,4 ); |
680 | mDocPrefs = new DocPrefs( name ); | 680 | mDocPrefs = new DocPrefs( name ); |
681 | 681 | ||
682 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 682 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
683 | mPopupMenu->setCheckable( true ); | 683 | mPopupMenu->setCheckable( true ); |
684 | mItemPopupMenu->setCheckable( true ); | 684 | mItemPopupMenu->setCheckable( true ); |
685 | 685 | ||
686 | 686 | ||
687 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 687 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
688 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 688 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
689 | 689 | ||
690 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 690 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
691 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 691 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
692 | 692 | ||
693 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 693 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
694 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 694 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
695 | 695 | ||
696 | 696 | ||
697 | // Double clicking conflicts with opening/closing the subtree | 697 | // Double clicking conflicts with opening/closing the subtree |
698 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 698 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
699 | SLOT( editItem( QListViewItem *) ) ); | 699 | SLOT( editItem( QListViewItem *) ) ); |
700 | /* | 700 | /* |
701 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 701 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
702 | const QPoint &,int ) ), | 702 | const QPoint &,int ) ), |
703 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 703 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
704 | */ | 704 | */ |
705 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 705 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
706 | const QPoint &,int ) ), | 706 | const QPoint &,int ) ), |
707 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 707 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
708 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 708 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
709 | SLOT( itemClicked( QListViewItem * ) ) ); | 709 | SLOT( itemClicked( QListViewItem * ) ) ); |
710 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 710 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
711 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 711 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
712 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 712 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
713 | SLOT( updateView() ) ); | 713 | SLOT( updateView() ) ); |
714 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 714 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
715 | SLOT( todoModified(Todo *, int) ) ); | 715 | SLOT( todoModified(Todo *, int) ) ); |
716 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 716 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
717 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 717 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
718 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 718 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
719 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 719 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
720 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 720 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
721 | SLOT( paintNeeded()) ); | 721 | SLOT( paintNeeded()) ); |
722 | 722 | ||
723 | #if 0 | 723 | #if 0 |
724 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 724 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
725 | SLOT(selectionChanged(QListViewItem *))); | 725 | SLOT(selectionChanged(QListViewItem *))); |
726 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 726 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
727 | SLOT(selectionChanged(QListViewItem *))); | 727 | SLOT(selectionChanged(QListViewItem *))); |
728 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 728 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
729 | SLOT(selectionChanged(QListViewItem *))); | 729 | SLOT(selectionChanged(QListViewItem *))); |
730 | #endif | 730 | #endif |
731 | 731 | ||
732 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 732 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
733 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 733 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
734 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 734 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
735 | 735 | ||
736 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 736 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
737 | SLOT( processSelectionChange() ) ); | 737 | SLOT( processSelectionChange() ) ); |
738 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 738 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
739 | SLOT( addQuickTodo() ) ); | 739 | SLOT( addQuickTodo() ) ); |
740 | 740 | ||
741 | } | 741 | } |
742 | 742 | ||
743 | KOTodoView::~KOTodoView() | 743 | KOTodoView::~KOTodoView() |
744 | { | 744 | { |
745 | 745 | ||
746 | #if QT_VERSION >= 0x030000 | 746 | #if QT_VERSION >= 0x030000 |
747 | 747 | ||
748 | #else | 748 | #else |
749 | delete mKOTodoViewWhatsThis; | 749 | delete mKOTodoViewWhatsThis; |
750 | #endif | 750 | #endif |
751 | 751 | ||
752 | delete mDocPrefs; | 752 | delete mDocPrefs; |
753 | } | 753 | } |
754 | QString KOTodoView::getWhatsThisText(QPoint p) | 754 | QString KOTodoView::getWhatsThisText(QPoint p) |
755 | { | 755 | { |
756 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 756 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
757 | if ( item ) | 757 | if ( item ) |
758 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 758 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
759 | KOPrefs::instance()->mWTshowDetails, | 759 | KOPrefs::instance()->mWTshowDetails, |
760 | KOPrefs::instance()->mWTshowCreated, | 760 | KOPrefs::instance()->mWTshowCreated, |
761 | KOPrefs::instance()->mWTshowChanged); | 761 | KOPrefs::instance()->mWTshowChanged); |
762 | return i18n("That is the todo view" ); | 762 | return i18n("That is the todo view" ); |
763 | 763 | ||
764 | } | 764 | } |
765 | 765 | ||
766 | void KOTodoView::jumpToDate () | 766 | void KOTodoView::jumpToDate () |
767 | { | 767 | { |
768 | // if (mActiveItem) { | 768 | // if (mActiveItem) { |
769 | // mActiveItem->todo()); | 769 | // mActiveItem->todo()); |
770 | // if ( mActiveItem->todo()->hasDueDate() ) | 770 | // if ( mActiveItem->todo()->hasDueDate() ) |
771 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 771 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
772 | } | 772 | } |
773 | void KOTodoView::paintNeeded() | 773 | void KOTodoView::paintNeeded() |
774 | { | 774 | { |
775 | if ( mPendingUpdateBeforeRepaint ) { | 775 | if ( mPendingUpdateBeforeRepaint ) { |
776 | updateView(); | 776 | updateView(); |
777 | mPendingUpdateBeforeRepaint = false; | 777 | mPendingUpdateBeforeRepaint = false; |
778 | } | 778 | } |
779 | } | 779 | } |
780 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 780 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
781 | { | 781 | { |
782 | if ( mPendingUpdateBeforeRepaint ) { | 782 | if ( mPendingUpdateBeforeRepaint ) { |
783 | updateView(); | 783 | updateView(); |
784 | mPendingUpdateBeforeRepaint = false; | 784 | mPendingUpdateBeforeRepaint = false; |
785 | } | 785 | } |
786 | KOrg::BaseView::paintEvent( pevent); | 786 | KOrg::BaseView::paintEvent( pevent); |
787 | } | 787 | } |
788 | 788 | ||
789 | void KOTodoView::updateView() | 789 | void KOTodoView::updateView() |
790 | { | 790 | { |
791 | pendingSubtodo = 0; | 791 | pendingSubtodo = 0; |
792 | if ( mBlockUpdate ) { | 792 | if ( mBlockUpdate ) { |
793 | return; | 793 | return; |
794 | } | 794 | } |
795 | if ( !isVisible() ) { | 795 | if ( !isVisible() ) { |
796 | mPendingUpdateBeforeRepaint = true; | 796 | mPendingUpdateBeforeRepaint = true; |
797 | return; | 797 | return; |
798 | } | 798 | } |
799 | //qDebug("KOTodoView::updateView() %x", this); | 799 | //qDebug("KOTodoView::updateView() %x", this); |
800 | if ( isFlatDisplay ) { | 800 | if ( isFlatDisplay ) { |
801 | displayAllFlat(); | 801 | displayAllFlat(); |
802 | return; | 802 | return; |
803 | } | 803 | } |
804 | storeCurrentItem(); | 804 | storeCurrentItem(); |
805 | //qDebug("update "); | 805 | //qDebug("update "); |
806 | // kdDebug() << "KOTodoView::updateView()" << endl; | 806 | // kdDebug() << "KOTodoView::updateView()" << endl; |
807 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 807 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
808 | 808 | ||
809 | 809 | ||
810 | mTodoListView->clear(); | 810 | mTodoListView->clear(); |
811 | if ( mName == "todolistsmall" ) { | 811 | if ( mName == "todolistsmall" ) { |
812 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 812 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
813 | int ps = fo.pointSize() -2; | 813 | int ps = fo.pointSize() -2; |
814 | if ( ps > 12 ) | 814 | if ( ps > 12 ) |
815 | ps -= 2; | 815 | ps -= 2; |
816 | fo.setPointSize( ps ); | 816 | fo.setPointSize( ps ); |
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
820 | mTodoListView->setFont( fo ); | 820 | mTodoListView->setFont( fo ); |
821 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 821 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
822 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 822 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
823 | QPtrList<Todo> todoList = calendar()->todos(); | 823 | QPtrList<Todo> todoList = calendar()->todos(); |
824 | 824 | ||
825 | /* | 825 | /* |
826 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 826 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
827 | Event *t; | 827 | Event *t; |
828 | for(t = todoList.first(); t; t = todoList.next()) { | 828 | for(t = todoList.first(); t; t = todoList.next()) { |
829 | kdDebug() << " " << t->getSummary() << endl; | 829 | kdDebug() << " " << t->getSummary() << endl; |
830 | 830 | ||
831 | if (t->getRelatedTo()) { | 831 | if (t->getRelatedTo()) { |
832 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 832 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
833 | } | 833 | } |
834 | 834 | ||
835 | QPtrList<Event> l = t->getRelations(); | 835 | QPtrList<Event> l = t->getRelations(); |
836 | Event *c; | 836 | Event *c; |
837 | for(c=l.first();c;c=l.next()) { | 837 | for(c=l.first();c;c=l.next()) { |
838 | kdDebug() << " - relation: " << c->getSummary() << endl; | 838 | kdDebug() << " - relation: " << c->getSummary() << endl; |
839 | } | 839 | } |
840 | } | 840 | } |
841 | */ | 841 | */ |
842 | 842 | ||
843 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 843 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
844 | // specific order of events. That means that we have to generate parent items | 844 | // specific order of events. That means that we have to generate parent items |
845 | // recursively for proper hierarchical display of Todos. | 845 | // recursively for proper hierarchical display of Todos. |
846 | mTodoMap.clear(); | 846 | mTodoMap.clear(); |
847 | Todo *todo; | 847 | Todo *todo; |
848 | todo = todoList.first();// todo; todo = todoList.next()) { | 848 | todo = todoList.first();// todo; todo = todoList.next()) { |
849 | while ( todo ) { | 849 | while ( todo ) { |
850 | bool next = true; | 850 | bool next = true; |
851 | // qDebug("todo %s ", todo->summary().latin1()); | 851 | // qDebug("todo %s ", todo->summary().latin1()); |
852 | Incidence *incidence = todo->relatedTo(); | 852 | Incidence *incidence = todo->relatedTo(); |
853 | while ( incidence ) { | 853 | while ( incidence ) { |
854 | if ( incidence->typeID() == todoID ) { | 854 | if ( incidence->typeID() == todoID ) { |
855 | //qDebug("related %s ",incidence->summary().latin1() ); | 855 | //qDebug("related %s ",incidence->summary().latin1() ); |
856 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 856 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
857 | //qDebug("related not found "); | 857 | //qDebug("related not found "); |
858 | todoList.remove( ); | 858 | todoList.remove( ); |
859 | todo = todoList.current(); | 859 | todo = todoList.current(); |
860 | next = false; | 860 | next = false; |
861 | incidence = 0; | 861 | incidence = 0; |
862 | 862 | ||
863 | } else { | 863 | } else { |
864 | //qDebug("related found "); | 864 | //qDebug("related found "); |
865 | incidence = incidence->relatedTo(); | 865 | incidence = incidence->relatedTo(); |
866 | } | 866 | } |
867 | } else | 867 | } else |
868 | incidence = 0; | 868 | incidence = 0; |
869 | } | 869 | } |
870 | if ( next ) | 870 | if ( next ) |
871 | todo = todoList.next(); | 871 | todo = todoList.next(); |
872 | } | 872 | } |
873 | 873 | ||
874 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 874 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
875 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 875 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
876 | { | 876 | { |
877 | insertTodoItem(todo); | 877 | insertTodoItem(todo); |
878 | } | 878 | } |
879 | } | 879 | } |
880 | // Restore opened/closed state | 880 | // Restore opened/closed state |
881 | mTodoListView->blockSignals( true ); | 881 | mTodoListView->blockSignals( true ); |
882 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 882 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
883 | mTodoListView->blockSignals( false ); | 883 | mTodoListView->blockSignals( false ); |
884 | resetCurrentItem(); | 884 | resetCurrentItem(); |
885 | } | 885 | } |
886 | 886 | ||
887 | void KOTodoView::storeCurrentItem() | 887 | void KOTodoView::storeCurrentItem() |
888 | { | 888 | { |
889 | mCurItem = 0; | 889 | mCurItem = 0; |
890 | mCurItemRootParent = 0; | 890 | mCurItemRootParent = 0; |
891 | mCurItemParent = 0; | 891 | mCurItemParent = 0; |
892 | mCurItemAbove = 0; | 892 | mCurItemAbove = 0; |
893 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 893 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
894 | if (mActiveItem) { | 894 | if (mActiveItem) { |
895 | mCurItem = mActiveItem->todo(); | 895 | mCurItem = mActiveItem->todo(); |
896 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 896 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
897 | if ( activeItemAbove ) | 897 | if ( activeItemAbove ) |
898 | mCurItemAbove = activeItemAbove->todo(); | 898 | mCurItemAbove = activeItemAbove->todo(); |
899 | mCurItemRootParent = mCurItem; | 899 | mCurItemRootParent = mCurItem; |
900 | mCurItemParent = mCurItemRootParent->relatedTo(); | 900 | mCurItemParent = mCurItemRootParent->relatedTo(); |
901 | while ( mCurItemRootParent->relatedTo() != 0 ) | 901 | while ( mCurItemRootParent->relatedTo() != 0 ) |
902 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 902 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
903 | } | 903 | } |
904 | mActiveItem = 0; | 904 | mActiveItem = 0; |
905 | } | 905 | } |
906 | 906 | ||
907 | void KOTodoView::resetCurrentItem() | 907 | void KOTodoView::resetCurrentItem() |
908 | { | 908 | { |
909 | //mTodoListView->setFocus(); | 909 | //mTodoListView->setFocus(); |
910 | KOTodoViewItem* foundItem = 0; | 910 | KOTodoViewItem* foundItem = 0; |
911 | KOTodoViewItem* foundItemRoot = 0; | 911 | KOTodoViewItem* foundItemRoot = 0; |
912 | KOTodoViewItem* foundItemParent = 0; | 912 | KOTodoViewItem* foundItemParent = 0; |
913 | KOTodoViewItem* foundItemAbove = 0; | 913 | KOTodoViewItem* foundItemAbove = 0; |
914 | if ( mTodoListView->firstChild () ) { | 914 | if ( mTodoListView->firstChild () ) { |
915 | if ( mCurItem ) { | 915 | if ( mCurItem ) { |
916 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 916 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
917 | while ( item ) { | 917 | while ( item ) { |
918 | if ( item->todo() == mCurItem ) { | 918 | if ( item->todo() == mCurItem ) { |
919 | foundItem = item; | 919 | foundItem = item; |
920 | break; | 920 | break; |
921 | } else if ( item->todo() == mCurItemAbove ) { | 921 | } else if ( item->todo() == mCurItemAbove ) { |
922 | foundItemAbove = item; | 922 | foundItemAbove = item; |
923 | 923 | ||
924 | } | 924 | } |
925 | if ( item->todo() == mCurItemRootParent ) { | 925 | if ( item->todo() == mCurItemRootParent ) { |
926 | foundItemRoot = item; | 926 | foundItemRoot = item; |
927 | } | 927 | } |
928 | if ( item->todo() == mCurItemParent ) { | 928 | if ( item->todo() == mCurItemParent ) { |
929 | foundItemParent = item; | 929 | foundItemParent = item; |
930 | } | 930 | } |
931 | item = (KOTodoViewItem*)item->itemBelow(); | 931 | item = (KOTodoViewItem*)item->itemBelow(); |
932 | } | 932 | } |
933 | if ( ! foundItem ) { | 933 | if ( ! foundItem ) { |
934 | if ( foundItemParent ) { | 934 | if ( foundItemParent ) { |
935 | foundItem = foundItemParent; | 935 | foundItem = foundItemParent; |
936 | } else { | 936 | } else { |
937 | if ( foundItemRoot ) | 937 | if ( foundItemRoot ) |
938 | foundItem = foundItemRoot; | 938 | foundItem = foundItemRoot; |
939 | else | 939 | else |
940 | foundItem = foundItemAbove; | 940 | foundItem = foundItemAbove; |
941 | } | 941 | } |
942 | } | 942 | } |
943 | } | 943 | } |
944 | if ( foundItem ) { | 944 | if ( foundItem ) { |
945 | mTodoListView->setSelected ( foundItem, true ); | 945 | mTodoListView->setSelected ( foundItem, true ); |
946 | mTodoListView->setCurrentItem( foundItem ); | 946 | mTodoListView->setCurrentItem( foundItem ); |
947 | mTodoListView->ensureItemVisible( foundItem ); | 947 | mTodoListView->ensureItemVisible( foundItem ); |
948 | } else { | 948 | } else { |
949 | if ( mTodoListView->firstChild () ) { | 949 | if ( mTodoListView->firstChild () ) { |
950 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 950 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
951 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 951 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
952 | } | 952 | } |
953 | } | 953 | } |
954 | } | 954 | } |
955 | processSelectionChange(); | 955 | processSelectionChange(); |
956 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 956 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
957 | } | 957 | } |
958 | void KOTodoView::resetFocusToList() | 958 | void KOTodoView::resetFocusToList() |
959 | { | 959 | { |
960 | topLevelWidget()->setActiveWindow(); | 960 | topLevelWidget()->setActiveWindow(); |
961 | mTodoListView->setFocus(); | 961 | mTodoListView->setFocus(); |
962 | } | 962 | } |
963 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 963 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
964 | bool KOTodoView::checkTodo( Todo * todo ) | 964 | bool KOTodoView::checkTodo( Todo * todo ) |
965 | { | 965 | { |
966 | 966 | ||
967 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 967 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
968 | return false; | 968 | return false; |
969 | if ( !todo->isCompleted() ) { | 969 | if ( !todo->isCompleted() ) { |
970 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 970 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
971 | return true; | 971 | return true; |
972 | } | 972 | } |
973 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 973 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
974 | if ( todo->hasStartDate() ) | 974 | if ( todo->hasStartDate() ) |
975 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 975 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
976 | return false; | 976 | return false; |
977 | if ( todo->hasDueDate() ) | 977 | if ( todo->hasDueDate() ) |
978 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 978 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
979 | return false; | 979 | return false; |
980 | } | 980 | } |
981 | return true; | 981 | return true; |
982 | } | 982 | } |
983 | 983 | ||
984 | void KOTodoView::restoreItemState( QListViewItem *item ) | 984 | void KOTodoView::restoreItemState( QListViewItem *item ) |
985 | { | 985 | { |
986 | pendingSubtodo = 0; | 986 | pendingSubtodo = 0; |
987 | while( item ) { | 987 | while( item ) { |
988 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 988 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
989 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 989 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
990 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 990 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
991 | item = item->nextSibling(); | 991 | item = item->nextSibling(); |
992 | } | 992 | } |
993 | } | 993 | } |
994 | 994 | ||
995 | 995 | ||
996 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 996 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
997 | KOTodoView::insertTodoItem(Todo *todo) | 997 | KOTodoView::insertTodoItem(Todo *todo) |
998 | { | 998 | { |
999 | 999 | ||
1000 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1000 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1001 | // TODO: Check, if dynmaic cast is necessary | 1001 | // TODO: Check, if dynmaic cast is necessary |
1002 | 1002 | ||
1003 | pendingSubtodo = 0; | 1003 | pendingSubtodo = 0; |
1004 | Incidence *incidence = todo->relatedTo(); | 1004 | Incidence *incidence = todo->relatedTo(); |
1005 | while ( incidence && !incidence->calEnabled() ) | 1005 | while ( incidence && !incidence->calEnabled() ) |
1006 | incidence = incidence->relatedTo(); | 1006 | incidence = incidence->relatedTo(); |
1007 | if (incidence && incidence->typeID() == todoID ) { | 1007 | if (incidence && incidence->typeID() == todoID ) { |
1008 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1008 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
1009 | 1009 | ||
1010 | // kdDebug() << " has Related" << endl; | 1010 | // kdDebug() << " has Related" << endl; |
1011 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1011 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1012 | itemIterator = mTodoMap.find(relatedTodo); | 1012 | itemIterator = mTodoMap.find(relatedTodo); |
1013 | if (itemIterator == mTodoMap.end()) { | 1013 | if (itemIterator == mTodoMap.end()) { |
1014 | // kdDebug() << " related not yet in list" << endl; | 1014 | // kdDebug() << " related not yet in list" << endl; |
1015 | itemIterator = insertTodoItem (relatedTodo); | 1015 | itemIterator = insertTodoItem (relatedTodo); |
1016 | } | 1016 | } |
1017 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 1017 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
1018 | // and one into the map. Sure finding is more easy but why? -zecke | 1018 | // and one into the map. Sure finding is more easy but why? -zecke |
1019 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 1019 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
1020 | return mTodoMap.insert(todo,todoItem); | 1020 | return mTodoMap.insert(todo,todoItem); |
1021 | } else { | 1021 | } else { |
1022 | // kdDebug() << " no Related" << endl; | 1022 | // kdDebug() << " no Related" << endl; |
1023 | // see above -zecke | 1023 | // see above -zecke |
1024 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1024 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1025 | return mTodoMap.insert(todo,todoItem); | 1025 | return mTodoMap.insert(todo,todoItem); |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | 1029 | ||
1030 | void KOTodoView::updateConfig() | 1030 | void KOTodoView::updateConfig() |
1031 | { | 1031 | { |
1032 | updateView(); | 1032 | updateView(); |
1033 | mTodoListView->repaintContents(); | 1033 | mTodoListView->repaintContents(); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1036 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1037 | { | 1037 | { |
1038 | QPtrList<Incidence> selected; | 1038 | QPtrList<Incidence> selected; |
1039 | 1039 | ||
1040 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1040 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1041 | // if (!item) item = mActiveItem; | 1041 | // if (!item) item = mActiveItem; |
1042 | if (item) selected.append(item->todo()); | 1042 | if (item) selected.append(item->todo()); |
1043 | 1043 | ||
1044 | return selected; | 1044 | return selected; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | QPtrList<Todo> KOTodoView::selectedTodos() | 1047 | QPtrList<Todo> KOTodoView::selectedTodos() |
1048 | { | 1048 | { |
1049 | QPtrList<Todo> selected; | 1049 | QPtrList<Todo> selected; |
1050 | 1050 | ||
1051 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1051 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1052 | // if (!item) item = mActiveItem; | 1052 | // if (!item) item = mActiveItem; |
1053 | if (item) selected.append(item->todo()); | 1053 | if (item) selected.append(item->todo()); |
1054 | 1054 | ||
1055 | return selected; | 1055 | return selected; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | void KOTodoView::changeEventDisplay(Event *, int) | 1058 | void KOTodoView::changeEventDisplay(Event *, int) |
1059 | { | 1059 | { |
1060 | updateView(); | 1060 | updateView(); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | void KOTodoView::showDates(const QDate &, const QDate &) | 1063 | void KOTodoView::showDates(const QDate &, const QDate &) |
1064 | { | 1064 | { |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | void KOTodoView::showEvents(QPtrList<Event>) | 1067 | void KOTodoView::showEvents(QPtrList<Event>) |
1068 | { | 1068 | { |
1069 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1069 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1072 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1073 | const QDate &td) | 1073 | const QDate &td) |
1074 | { | 1074 | { |
1075 | #ifndef KORG_NOPRINTER | 1075 | #ifndef KORG_NOPRINTER |
1076 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1076 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1077 | #endif | 1077 | #endif |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | void KOTodoView::editItem(QListViewItem *item ) | 1080 | void KOTodoView::editItem(QListViewItem *item ) |
1081 | { | 1081 | { |
1082 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1082 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1085 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1086 | { | 1086 | { |
1087 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1087 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1090 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1091 | { | 1091 | { |
1092 | pendingSubtodo = 0; | 1092 | pendingSubtodo = 0; |
1093 | mActiveItem = (KOTodoViewItem *)item; | 1093 | mActiveItem = (KOTodoViewItem *)item; |
1094 | if (item) { | 1094 | if (item) { |
1095 | switch (column){ | 1095 | switch (column){ |
1096 | case 1: | 1096 | case 1: |
1097 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1097 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1098 | case 2: | 1098 | case 2: |
1099 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1099 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1100 | case 3: | 1100 | case 3: |
1101 | moveTodo(); | 1101 | moveTodo(); |
1102 | break; | 1102 | break; |
1103 | case 8: | 1103 | case 8: |
1104 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1104 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1105 | case 9: | 1105 | case 9: |
1106 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1106 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1107 | default: | 1107 | default: |
1108 | mItemPopupMenu->popup(QCursor::pos()); | 1108 | mItemPopupMenu->popup(QCursor::pos()); |
1109 | } | 1109 | } |
1110 | } else mPopupMenu->popup(QCursor::pos()); | 1110 | } else mPopupMenu->popup(QCursor::pos()); |
1111 | } | 1111 | } |
1112 | void KOTodoView::newTodo() | 1112 | void KOTodoView::newTodo() |
1113 | { | 1113 | { |
1114 | emit newTodoSignal(); | 1114 | emit newTodoSignal(); |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | void KOTodoView::newSubTodo() | 1117 | void KOTodoView::newSubTodo() |
1118 | { | 1118 | { |
1119 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1119 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1120 | if (mActiveItem) { | 1120 | if (mActiveItem) { |
1121 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add a new Todo") ) { | 1121 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add a new Todo") ) { |
1122 | addQuickTodoPar( mActiveItem->todo()); | 1122 | addQuickTodoPar( mActiveItem->todo()); |
1123 | } else | 1123 | } else |
1124 | emit newSubTodoSignal(mActiveItem->todo()); | 1124 | emit newSubTodoSignal(mActiveItem->todo()); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | void KOTodoView::unparentTodo() | 1127 | void KOTodoView::unparentTodo() |
1128 | { | 1128 | { |
1129 | if (mActiveItem) { | 1129 | if (mActiveItem) { |
1130 | emit unparentTodoSignal(mActiveItem->todo()); | 1130 | emit unparentTodoSignal(mActiveItem->todo()); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | void KOTodoView::reparentTodo() | 1134 | void KOTodoView::reparentTodo() |
1135 | { | 1135 | { |
1136 | if (mActiveItem) { | 1136 | if (mActiveItem) { |
1137 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1137 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1138 | pendingSubtodo = mActiveItem; | 1138 | pendingSubtodo = mActiveItem; |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | void KOTodoView::editTodo() | 1141 | void KOTodoView::editTodo() |
1142 | { | 1142 | { |
1143 | if (mActiveItem) { | 1143 | if (mActiveItem) { |
1144 | emit editTodoSignal(mActiveItem->todo()); | 1144 | emit editTodoSignal(mActiveItem->todo()); |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | void KOTodoView::cloneTodo() | 1147 | void KOTodoView::cloneTodo() |
1148 | { | 1148 | { |
1149 | if (mActiveItem) { | 1149 | if (mActiveItem) { |
1150 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1150 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1151 | } | 1151 | } |
1152 | } | 1152 | } |
1153 | void KOTodoView::cancelTodo() | 1153 | void KOTodoView::cancelTodo() |
1154 | { | 1154 | { |
1155 | if (mActiveItem) { | 1155 | if (mActiveItem) { |
1156 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1156 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | void KOTodoView::moveTodo() | 1159 | void KOTodoView::moveTodo() |
1160 | { | 1160 | { |
1161 | if (mActiveItem) { | 1161 | if (mActiveItem) { |
1162 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1162 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | void KOTodoView::beamTodo() | 1165 | void KOTodoView::beamTodo() |
1166 | { | 1166 | { |
1167 | if (mActiveItem) { | 1167 | if (mActiveItem) { |
1168 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1168 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | 1172 | ||
1173 | void KOTodoView::showTodo() | 1173 | void KOTodoView::showTodo() |
1174 | { | 1174 | { |
1175 | if (mActiveItem) { | 1175 | if (mActiveItem) { |
1176 | emit showTodoSignal(mActiveItem->todo()); | 1176 | emit showTodoSignal(mActiveItem->todo()); |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | void KOTodoView::deleteTodo() | 1180 | void KOTodoView::deleteTodo() |
1181 | { | 1181 | { |
1182 | if (mActiveItem) { | 1182 | if (mActiveItem) { |
1183 | emit deleteTodoSignal(mActiveItem->todo()); | 1183 | emit deleteTodoSignal(mActiveItem->todo()); |
1184 | } | 1184 | } |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | void KOTodoView::setNewPriority(int index) | 1187 | void KOTodoView::setNewPriority(int index) |
1188 | { | 1188 | { |
1189 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1189 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1190 | mActiveItem->todo()->setPriority(mPriority[index]); | 1190 | mActiveItem->todo()->setPriority(mPriority[index]); |
1191 | mActiveItem->construct(); | 1191 | mActiveItem->construct(); |
1192 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1192 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1193 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1193 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1194 | } | 1194 | } |
1195 | processSelectionChange(); | 1195 | processSelectionChange(); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | void KOTodoView::setNewPercentage(int index) | 1198 | void KOTodoView::setNewPercentage(int index) |
1199 | { | 1199 | { |
1200 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1200 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1201 | 1201 | ||
1202 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1202 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1203 | mActiveItem->setOn( true ); | 1203 | mActiveItem->setOn( true ); |
1204 | processSelectionChange(); | 1204 | processSelectionChange(); |
1205 | return; | 1205 | return; |
1206 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1206 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1207 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1207 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1208 | if ( par && par->isOn() ) | 1208 | if ( par && par->isOn() ) |
1209 | par->setOn( false ); | 1209 | par->setOn( false ); |
1210 | } | 1210 | } |
1211 | if (mPercentage[index] == 100) { | 1211 | if (mPercentage[index] == 100) { |
1212 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1212 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1213 | } else { | 1213 | } else { |
1214 | mActiveItem->todo()->setCompleted(false); | 1214 | mActiveItem->todo()->setCompleted(false); |
1215 | } | 1215 | } |
1216 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1216 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1217 | mActiveItem->construct(); | 1217 | mActiveItem->construct(); |
1218 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1218 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1219 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1219 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1220 | } | 1220 | } |
1221 | processSelectionChange(); | 1221 | processSelectionChange(); |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | void KOTodoView::fillCategories () | 1224 | void KOTodoView::fillCategories () |
1225 | { | 1225 | { |
1226 | mCategoryPopupMenu->clear(); | 1226 | mCategoryPopupMenu->clear(); |
1227 | if ( ! mActiveItem ) return; | 1227 | if ( ! mActiveItem ) return; |
1228 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1228 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1229 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1229 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1230 | it != KOPrefs::instance()->mCustomCategories.end (); | 1230 | it != KOPrefs::instance()->mCustomCategories.end (); |
1231 | ++it) { | 1231 | ++it) { |
1232 | int index = mCategoryPopupMenu->insertItem (*it); | 1232 | int index = mCategoryPopupMenu->insertItem (*it); |
1233 | mCategory[index] = *it; | 1233 | mCategory[index] = *it; |
1234 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1234 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | void KOTodoView::fillCal () | 1237 | void KOTodoView::fillCal () |
1238 | { | 1238 | { |
1239 | mCalPopupMenu->clear(); | 1239 | mCalPopupMenu->clear(); |
1240 | if (!mActiveItem) return; | 1240 | if (!mActiveItem) return; |
1241 | bool readO = mActiveItem->todo()->isReadOnly(); | 1241 | bool readO = mActiveItem->todo()->isReadOnly(); |
1242 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1242 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1243 | while ( kkf ) { | 1243 | while ( kkf ) { |
1244 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1244 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1245 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1245 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1246 | mCalPopupMenu->setItemEnabled( index, false ); | 1246 | mCalPopupMenu->setItemEnabled( index, false ); |
1247 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1247 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1248 | kkf = KOPrefs::instance()->mCalendars.next(); | 1248 | kkf = KOPrefs::instance()->mCalendars.next(); |
1249 | } | 1249 | } |
1250 | } | 1250 | } |
1251 | void KOTodoView::changedCal (int index ) | 1251 | void KOTodoView::changedCal (int index ) |
1252 | { | 1252 | { |
1253 | if (!mActiveItem) return; | 1253 | if (!mActiveItem) return; |
1254 | mActiveItem->todo()->setCalID( index ); | 1254 | mActiveItem->todo()->setCalID( index ); |
1255 | mActiveItem->construct(); | 1255 | mActiveItem->construct(); |
1256 | } | 1256 | } |
1257 | void KOTodoView::changedCategories(int index) | 1257 | void KOTodoView::changedCategories(int index) |
1258 | { | 1258 | { |
1259 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1259 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1260 | QStringList categories = mActiveItem->todo()->categories (); | 1260 | QStringList categories = mActiveItem->todo()->categories (); |
1261 | QString colcat = categories.first(); | 1261 | QString colcat = categories.first(); |
1262 | if (categories.find (mCategory[index]) != categories.end ()) | 1262 | if (categories.find (mCategory[index]) != categories.end ()) |
1263 | categories.remove (mCategory[index]); | 1263 | categories.remove (mCategory[index]); |
1264 | else | 1264 | else |
1265 | categories.insert (categories.end(), mCategory[index]); | 1265 | categories.insert (categories.end(), mCategory[index]); |
1266 | categories.sort (); | 1266 | categories.sort (); |
1267 | if ( !colcat.isEmpty() ) { | 1267 | if ( !colcat.isEmpty() ) { |
1268 | if ( categories.find ( colcat ) != categories.end () ) { | 1268 | if ( categories.find ( colcat ) != categories.end () ) { |
1269 | categories.remove( colcat ); | 1269 | categories.remove( colcat ); |
1270 | categories.prepend( colcat ); | 1270 | categories.prepend( colcat ); |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | mActiveItem->todo()->setCategories (categories); | 1273 | mActiveItem->todo()->setCategories (categories); |
1274 | mActiveItem->construct(); | 1274 | mActiveItem->construct(); |
1275 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1275 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1276 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1276 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1277 | } | 1277 | } |
1278 | } | 1278 | } |
1279 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1279 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1280 | { | 1280 | { |
1281 | if ( pendingSubtodo != 0 ) { | 1281 | if ( pendingSubtodo != 0 ) { |
1282 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1282 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1283 | } | 1283 | } |
1284 | pendingSubtodo = 0; | 1284 | pendingSubtodo = 0; |
1285 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1285 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1286 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1286 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1287 | //qDebug("ROW %d ", row); | 1287 | //qDebug("ROW %d ", row); |
1288 | if (!item) { | 1288 | if (!item) { |
1289 | newTodo(); | 1289 | newTodo(); |
1290 | return; | 1290 | return; |
1291 | } else { | 1291 | } else { |
1292 | if ( row == 1 ) { | 1292 | if ( row == 1 ) { |
1293 | mActiveItem = (KOTodoViewItem *) item; | 1293 | mActiveItem = (KOTodoViewItem *) item; |
1294 | newSubTodo(); | 1294 | newSubTodo(); |
1295 | return; | 1295 | return; |
1296 | } | 1296 | } |
1297 | if ( row == 5 || row == 6 || row == 2) { | 1297 | if ( row == 5 || row == 6 || row == 2) { |
1298 | mActiveItem = (KOTodoViewItem *) item; | 1298 | mActiveItem = (KOTodoViewItem *) item; |
1299 | Todo * t = mActiveItem->todo(); | 1299 | Todo * t = mActiveItem->todo(); |
1300 | if ( t->isRunning() ) { | 1300 | if ( t->isRunning() ) { |
1301 | if ( t->runTime() < 15) { | 1301 | if ( t->runTime() < 15) { |
1302 | t->stopRunning(); | 1302 | t->stopRunning(); |
1303 | mActiveItem->construct(); | 1303 | mActiveItem->construct(); |
1304 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1304 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1305 | return; | 1305 | return; |
1306 | } | 1306 | } |
1307 | else | 1307 | else |
1308 | toggleRunningItem(); | 1308 | toggleRunningItem(); |
1309 | return; | 1309 | return; |
1310 | } else { | 1310 | } else { |
1311 | t->setRunning( true ); | 1311 | t->setRunning( true ); |
1312 | mActiveItem->construct(); | 1312 | mActiveItem->construct(); |
1313 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1313 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1314 | return; | 1314 | return; |
1315 | } | 1315 | } |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
1318 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1318 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1319 | editItem( item ); | 1319 | editItem( item ); |
1320 | else | 1320 | else |
1321 | showItem( item , QPoint(), 0 ); | 1321 | showItem( item , QPoint(), 0 ); |
1322 | } | 1322 | } |
1323 | void KOTodoView::toggleRunningItem() | 1323 | void KOTodoView::toggleRunningItem() |
1324 | { | 1324 | { |
1325 | // qDebug("KOTodoView::toggleRunning() "); | 1325 | // qDebug("KOTodoView::toggleRunning() "); |
1326 | if ( ! mActiveItem ) | 1326 | if ( ! mActiveItem ) |
1327 | return; | 1327 | return; |
1328 | Todo * t = mActiveItem->todo(); | 1328 | Todo * t = mActiveItem->todo(); |
1329 | if ( t->isRunning() ) { | 1329 | if ( t->isRunning() ) { |
1330 | KOStopTodoPrefs tp ( t, this ); | 1330 | KOStopTodoPrefs tp ( t, this ); |
1331 | if (QApplication::desktop()->width() <= 800 ){ | 1331 | if (QApplication::desktop()->width() <= 800 ){ |
1332 | int wid = tp.width(); | 1332 | int wid = tp.width(); |
1333 | int hei = tp.height(); | 1333 | int hei = tp.height(); |
1334 | int xx = (QApplication::desktop()->width()-wid)/2; | 1334 | int xx = (QApplication::desktop()->width()-wid)/2; |
1335 | int yy = (QApplication::desktop()->height()-hei)/2; | 1335 | int yy = (QApplication::desktop()->height()-hei)/2; |
1336 | tp.setGeometry( xx,yy,wid,hei ); | 1336 | tp.setGeometry( xx,yy,wid,hei ); |
1337 | } | 1337 | } |
1338 | tp.exec(); | 1338 | tp.exec(); |
1339 | mActiveItem->construct(); | 1339 | mActiveItem->construct(); |
1340 | } else { | 1340 | } else { |
1341 | KOStartTodoPrefs tp ( t->summary(), this ); | 1341 | KOStartTodoPrefs tp ( t->summary(), this ); |
1342 | if (QApplication::desktop()->width() <= 800 ){ | 1342 | if (QApplication::desktop()->width() <= 800 ){ |
1343 | int wid = tp.width(); | 1343 | int wid = tp.width(); |
1344 | int hei = tp.height(); | 1344 | int hei = tp.height(); |
1345 | int xx = (QApplication::desktop()->width()-wid)/2; | 1345 | int xx = (QApplication::desktop()->width()-wid)/2; |
1346 | int yy = (QApplication::desktop()->height()-hei)/2; | 1346 | int yy = (QApplication::desktop()->height()-hei)/2; |
1347 | tp.setGeometry( xx,yy,wid,hei ); | 1347 | tp.setGeometry( xx,yy,wid,hei ); |
1348 | } | 1348 | } |
1349 | if ( !tp.exec() ) return; | 1349 | if ( !tp.exec() ) return; |
1350 | if ( tp.stopAll() ) { | 1350 | if ( tp.stopAll() ) { |
1351 | mCalendar->stopAllTodos(); | 1351 | mCalendar->stopAllTodos(); |
1352 | t->setRunning( true ); | 1352 | t->setRunning( true ); |
1353 | updateView(); | 1353 | updateView(); |
1354 | } else { | 1354 | } else { |
1355 | t->setRunning( true ); | 1355 | t->setRunning( true ); |
1356 | mActiveItem->construct(); | 1356 | mActiveItem->construct(); |
1357 | } | 1357 | } |
1358 | } | 1358 | } |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | void KOTodoView::itemClicked(QListViewItem *item) | 1361 | void KOTodoView::itemClicked(QListViewItem *item) |
1362 | { | 1362 | { |
1363 | //qDebug("KOTodoView::itemClicked %d", item); | 1363 | //qDebug("KOTodoView::itemClicked %d", item); |
1364 | if (!item) { | 1364 | if (!item) { |
1365 | if ( pendingSubtodo != 0 ) { | 1365 | if ( pendingSubtodo != 0 ) { |
1366 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1366 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1367 | } | 1367 | } |
1368 | pendingSubtodo = 0; | 1368 | pendingSubtodo = 0; |
1369 | return; | 1369 | return; |
1370 | } | 1370 | } |
1371 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1371 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1372 | if ( pendingSubtodo != 0 ) { | 1372 | if ( pendingSubtodo != 0 ) { |
1373 | bool allowReparent = true; | 1373 | bool allowReparent = true; |
1374 | QListViewItem *par = item; | 1374 | QListViewItem *par = item; |
1375 | while ( par ) { | 1375 | while ( par ) { |
1376 | if ( par == pendingSubtodo ) { | 1376 | if ( par == pendingSubtodo ) { |
1377 | allowReparent = false; | 1377 | allowReparent = false; |
1378 | break; | 1378 | break; |
1379 | } | 1379 | } |
1380 | par = par->parent(); | 1380 | par = par->parent(); |
1381 | } | 1381 | } |
1382 | if ( !allowReparent ) { | 1382 | if ( !allowReparent ) { |
1383 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1383 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1384 | pendingSubtodo = 0; | 1384 | pendingSubtodo = 0; |
1385 | } else { | 1385 | } else { |
1386 | Todo* newParent = todoItem->todo(); | 1386 | Todo* newParent = todoItem->todo(); |
1387 | Todo* newSub = pendingSubtodo->todo(); | 1387 | Todo* newSub = pendingSubtodo->todo(); |
1388 | pendingSubtodo = 0; | 1388 | pendingSubtodo = 0; |
1389 | emit reparentTodoSignal( newParent,newSub ); | 1389 | emit reparentTodoSignal( newParent,newSub ); |
1390 | return; | 1390 | return; |
1391 | } | 1391 | } |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | void KOTodoView::setDocumentId( const QString &id ) | 1396 | void KOTodoView::setDocumentId( const QString &id ) |
1397 | { | 1397 | { |
1398 | 1398 | ||
1399 | mDocPrefs->setDoc( id ); | 1399 | mDocPrefs->setDoc( id ); |
1400 | } | 1400 | } |
1401 | 1401 | ||
1402 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1402 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1403 | { | 1403 | { |
1404 | if (!item) return; | 1404 | if (!item) return; |
1405 | 1405 | ||
1406 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1406 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1407 | 1407 | ||
1408 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1408 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1409 | 1409 | ||
1410 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1410 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1413 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1414 | { | 1414 | { |
1415 | mTodoListView->saveLayout(config,group); | 1415 | mTodoListView->saveLayout(config,group); |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1418 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1419 | { | 1419 | { |
1420 | mTodoListView->restoreLayout(config,group); | 1420 | mTodoListView->restoreLayout(config,group); |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | void KOTodoView::processSelectionChange() | 1423 | void KOTodoView::processSelectionChange() |
1424 | { | 1424 | { |
1425 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1425 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1426 | 1426 | ||
1427 | KOTodoViewItem *item = | 1427 | KOTodoViewItem *item = |
1428 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1428 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1429 | 1429 | ||
1430 | if ( !item ) { | 1430 | if ( !item ) { |
1431 | emit incidenceSelected( 0 ); | 1431 | emit incidenceSelected( 0 ); |
1432 | mNewSubBut->setEnabled( false ); | 1432 | mNewSubBut->setEnabled( false ); |
1433 | } else { | 1433 | } else { |
1434 | emit incidenceSelected( item->todo() ); | 1434 | emit incidenceSelected( item->todo() ); |
1435 | mNewSubBut->setEnabled( true ); | 1435 | mNewSubBut->setEnabled( true ); |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | void KOTodoView::modified(bool b) | 1439 | void KOTodoView::modified(bool b) |
1440 | { | 1440 | { |
1441 | emit isModified(b); | 1441 | emit isModified(b); |
1442 | } | 1442 | } |
1443 | void KOTodoView::setTodoModified( Todo* todo ) | 1443 | void KOTodoView::setTodoModified( Todo* todo ) |
1444 | { | 1444 | { |
1445 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1445 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1446 | } | 1446 | } |
1447 | void KOTodoView::clearSelection() | 1447 | void KOTodoView::clearSelection() |
1448 | { | 1448 | { |
1449 | mTodoListView->selectAll( false ); | 1449 | mTodoListView->selectAll( false ); |
1450 | } | 1450 | } |
1451 | void KOTodoView::setAllOpen() | 1451 | void KOTodoView::setAllOpen() |
1452 | { | 1452 | { |
1453 | if ( isFlatDisplay ) { | 1453 | if ( isFlatDisplay ) { |
1454 | isFlatDisplay = false; | 1454 | isFlatDisplay = false; |
1455 | mPopupMenu->setItemChecked( 8,false ); | 1455 | mPopupMenu->setItemChecked( 8,false ); |
1456 | updateView(); | 1456 | updateView(); |
1457 | } else { | 1457 | } else { |
1458 | storeCurrentItem(); | 1458 | storeCurrentItem(); |
1459 | } | 1459 | } |
1460 | setOpen(mTodoListView->firstChild(), true); | 1460 | setOpen(mTodoListView->firstChild(), true); |
1461 | resetCurrentItem(); | 1461 | resetCurrentItem(); |
1462 | } | 1462 | } |
1463 | void KOTodoView::setAllClose() | 1463 | void KOTodoView::setAllClose() |
1464 | { | 1464 | { |
1465 | if ( isFlatDisplay ) { | 1465 | if ( isFlatDisplay ) { |
1466 | isFlatDisplay = false; | 1466 | isFlatDisplay = false; |
1467 | mPopupMenu->setItemChecked( 8,false ); | 1467 | mPopupMenu->setItemChecked( 8,false ); |
1468 | updateView(); | 1468 | updateView(); |
1469 | } else { | 1469 | } else { |
1470 | storeCurrentItem(); | 1470 | storeCurrentItem(); |
1471 | } | 1471 | } |
1472 | setOpen(mTodoListView->firstChild(), false); | 1472 | setOpen(mTodoListView->firstChild(), false); |
1473 | resetCurrentItem(); | 1473 | resetCurrentItem(); |
1474 | } | 1474 | } |
1475 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1475 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1476 | { | 1476 | { |
1477 | 1477 | ||
1478 | while ( item ) { | 1478 | while ( item ) { |
1479 | setOpen( item->firstChild(), setOpenI ); | 1479 | setOpen( item->firstChild(), setOpenI ); |
1480 | item->setOpen( setOpenI ); | 1480 | item->setOpen( setOpenI ); |
1481 | item = item->nextSibling(); | 1481 | item = item->nextSibling(); |
1482 | } | 1482 | } |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | void KOTodoView::displayAllFlat() | 1485 | void KOTodoView::displayAllFlat() |
1486 | { | 1486 | { |
1487 | storeCurrentItem(); | 1487 | storeCurrentItem(); |
1488 | pendingSubtodo = 0; | 1488 | pendingSubtodo = 0; |
1489 | if ( mBlockUpdate ) { | 1489 | if ( mBlockUpdate ) { |
1490 | return; | 1490 | return; |
1491 | } | 1491 | } |
1492 | mPopupMenu->setItemChecked( 8,true ); | 1492 | mPopupMenu->setItemChecked( 8,true ); |
1493 | isFlatDisplay = true; | 1493 | isFlatDisplay = true; |
1494 | QPtrList<Todo> todoList = calendar()->todos(); | 1494 | QPtrList<Todo> todoList = calendar()->todos(); |
1495 | mTodoMap.clear(); | 1495 | mTodoMap.clear(); |
1496 | mTodoListView->clear(); | 1496 | mTodoListView->clear(); |
1497 | Todo *todo; | 1497 | Todo *todo; |
1498 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1498 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1499 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1499 | if ( checkTodo( todo ) ) { |
1500 | mTodoMap.insert(todo,todoItem); | 1500 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1501 | mTodoMap.insert(todo,todoItem); | ||
1502 | } | ||
1501 | } | 1503 | } |
1502 | resetCurrentItem(); | 1504 | resetCurrentItem(); |
1503 | } | 1505 | } |
1504 | 1506 | ||
1505 | void KOTodoView::setAllFlat() | 1507 | void KOTodoView::setAllFlat() |
1506 | { | 1508 | { |
1507 | if ( isFlatDisplay ) { | 1509 | if ( isFlatDisplay ) { |
1508 | isFlatDisplay = false; | 1510 | isFlatDisplay = false; |
1509 | mPopupMenu->setItemChecked( 8,false ); | 1511 | mPopupMenu->setItemChecked( 8,false ); |
1510 | updateView(); | 1512 | updateView(); |
1511 | return; | 1513 | return; |
1512 | } | 1514 | } |
1513 | displayAllFlat(); | 1515 | displayAllFlat(); |
1514 | } | 1516 | } |
1515 | 1517 | ||
1516 | void KOTodoView::purgeCompleted() | 1518 | void KOTodoView::purgeCompleted() |
1517 | { | 1519 | { |
1518 | emit purgeCompletedSignal(); | 1520 | emit purgeCompletedSignal(); |
1519 | 1521 | ||
1520 | } | 1522 | } |
1521 | void KOTodoView::toggleQuickTodo() | 1523 | void KOTodoView::toggleQuickTodo() |
1522 | { | 1524 | { |
1523 | if ( mQuickBar->isVisible() ) { | 1525 | if ( mQuickBar->isVisible() ) { |
1524 | mQuickBar->hide(); | 1526 | mQuickBar->hide(); |
1525 | KOPrefs::instance()->mEnableQuickTodo = false; | 1527 | KOPrefs::instance()->mEnableQuickTodo = false; |
1526 | } | 1528 | } |
1527 | else { | 1529 | else { |
1528 | mQuickBar->show(); | 1530 | mQuickBar->show(); |
1529 | KOPrefs::instance()->mEnableQuickTodo = true; | 1531 | KOPrefs::instance()->mEnableQuickTodo = true; |
1530 | } | 1532 | } |
1531 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1533 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1532 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1534 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1533 | } | 1535 | } |
1534 | 1536 | ||
1535 | void KOTodoView::toggleRunning() | 1537 | void KOTodoView::toggleRunning() |
1536 | { | 1538 | { |
1537 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1539 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1538 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1540 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1539 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1541 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1540 | updateView(); | 1542 | updateView(); |
1541 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 1543 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
1542 | topLevelWidget()->setCaption(i18n("Hide not Running")); | 1544 | topLevelWidget()->setCaption(i18n("Hide not Running")); |
1543 | else | 1545 | else |
1544 | topLevelWidget()->setCaption(i18n("Show not Running")); | 1546 | topLevelWidget()->setCaption(i18n("Show not Running")); |
1545 | } | 1547 | } |
1546 | 1548 | ||
1547 | void KOTodoView::toggleCompleted() | 1549 | void KOTodoView::toggleCompleted() |
1548 | { | 1550 | { |
1549 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1551 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1550 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1552 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1551 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1553 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1552 | updateView(); | 1554 | updateView(); |
1553 | if ( KOPrefs::instance()->mShowCompletedTodo ) | 1555 | if ( KOPrefs::instance()->mShowCompletedTodo ) |
1554 | topLevelWidget()->setCaption(i18n("Show Completed")); | 1556 | topLevelWidget()->setCaption(i18n("Show Completed")); |
1555 | else | 1557 | else |
1556 | topLevelWidget()->setCaption(i18n("Hide Completed")); | 1558 | topLevelWidget()->setCaption(i18n("Hide Completed")); |
1557 | } | 1559 | } |
1558 | 1560 | ||
1559 | void KOTodoView::addQuickTodo() | 1561 | void KOTodoView::addQuickTodo() |
1560 | { | 1562 | { |
1561 | addQuickTodoPar( 0 ); | 1563 | addQuickTodoPar( 0 ); |
1562 | } | 1564 | } |
1563 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) | 1565 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) |
1564 | { | 1566 | { |
1565 | Todo *todo = new Todo(); | 1567 | Todo *todo = new Todo(); |
1566 | todo->setSummary(mQuickAdd->text()); | 1568 | todo->setSummary(mQuickAdd->text()); |
1567 | todo->setOrganizer(KOPrefs::instance()->email()); | 1569 | todo->setOrganizer(KOPrefs::instance()->email()); |
1568 | if ( parentTodo ) { | 1570 | if ( parentTodo ) { |
1569 | todo->setRelatedTo(parentTodo); | 1571 | todo->setRelatedTo(parentTodo); |
1570 | 1572 | ||
1571 | todo->setCategories (parentTodo->categoriesStr ()); | 1573 | todo->setCategories (parentTodo->categoriesStr ()); |
1572 | todo->setSecrecy (parentTodo->secrecy ()); | 1574 | todo->setSecrecy (parentTodo->secrecy ()); |
1573 | if ( parentTodo->priority() < 3 ) | 1575 | if ( parentTodo->priority() < 3 ) |
1574 | todo->setPriority( parentTodo->priority() ); | 1576 | todo->setPriority( parentTodo->priority() ); |
1575 | todo->setCalID( parentTodo->calID() ); | 1577 | todo->setCalID( parentTodo->calID() ); |
1576 | } else { | 1578 | } else { |
1577 | CalFilter * cf = mCalendar->filter(); | 1579 | CalFilter * cf = mCalendar->filter(); |
1578 | if ( cf ) { | 1580 | if ( cf ) { |
1579 | if ( cf->isEnabled()&& cf->showCategories()) { | 1581 | if ( cf->isEnabled()&& cf->showCategories()) { |
1580 | todo->setCategories(cf->categoryList()); | 1582 | todo->setCategories(cf->categoryList()); |
1581 | } | 1583 | } |
1582 | if ( cf->isEnabled() ) | 1584 | if ( cf->isEnabled() ) |
1583 | todo->setSecrecy( cf->getSecrecy()); | 1585 | todo->setSecrecy( cf->getSecrecy()); |
1584 | } | 1586 | } |
1585 | } | 1587 | } |
1586 | mCalendar->addTodo(todo); | 1588 | mCalendar->addTodo(todo); |
1587 | mQuickAdd->setText(""); | 1589 | mQuickAdd->setText(""); |
1588 | todoModified (todo, KOGlobals::EVENTADDED ); | 1590 | todoModified (todo, KOGlobals::EVENTADDED ); |
1589 | updateView(); | 1591 | updateView(); |
1590 | 1592 | ||
1591 | } | 1593 | } |
1592 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1594 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1593 | { | 1595 | { |
1594 | // e->ignore(); | 1596 | // e->ignore(); |
1595 | //return; | 1597 | //return; |
1596 | //qDebug("KOTodoView::keyPressEvent "); | 1598 | //qDebug("KOTodoView::keyPressEvent "); |
1597 | switch ( e->key() ) { | 1599 | switch ( e->key() ) { |
1598 | case Qt::Key_Down: | 1600 | case Qt::Key_Down: |
1599 | case Qt::Key_Up: | 1601 | case Qt::Key_Up: |
1600 | QWidget::keyPressEvent ( e ); | 1602 | QWidget::keyPressEvent ( e ); |
1601 | break; | 1603 | break; |
1602 | 1604 | ||
1603 | case Qt::Key_Q: | 1605 | case Qt::Key_Q: |
1604 | toggleQuickTodo(); | 1606 | toggleQuickTodo(); |
1605 | break; | 1607 | break; |
1606 | case Qt::Key_U: | 1608 | case Qt::Key_U: |
1607 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1609 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1608 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1610 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1609 | unparentTodo(); | 1611 | unparentTodo(); |
1610 | e->accept(); | 1612 | e->accept(); |
1611 | } else | 1613 | } else |
1612 | e->ignore(); | 1614 | e->ignore(); |
1613 | break; | 1615 | break; |
1614 | case Qt::Key_S: | 1616 | case Qt::Key_S: |
1615 | if ( e->state() == Qt::ControlButton ) { | 1617 | if ( e->state() == Qt::ControlButton ) { |
1616 | e->ignore(); | 1618 | e->ignore(); |
1617 | break; | 1619 | break; |
1618 | } | 1620 | } |
1619 | if ( e->state() == Qt::ShiftButton ) { | 1621 | if ( e->state() == Qt::ShiftButton ) { |
1620 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1622 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1621 | reparentTodo(); | 1623 | reparentTodo(); |
1622 | e->accept(); | 1624 | e->accept(); |
1623 | } else | 1625 | } else |
1624 | e->ignore(); | 1626 | e->ignore(); |
1625 | break; | 1627 | break; |
1626 | case Qt::Key_P: | 1628 | case Qt::Key_P: |
1627 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1629 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1628 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1630 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1629 | if ( pendingSubtodo ) | 1631 | if ( pendingSubtodo ) |
1630 | itemClicked(mActiveItem); | 1632 | itemClicked(mActiveItem); |
1631 | e->accept(); | 1633 | e->accept(); |
1632 | } else | 1634 | } else |
1633 | e->ignore(); | 1635 | e->ignore(); |
1634 | break; | 1636 | break; |
1635 | case Qt::Key_Escape: | 1637 | case Qt::Key_Escape: |
1636 | if ( pendingSubtodo ) { | 1638 | if ( pendingSubtodo ) { |
1637 | itemClicked(0); | 1639 | itemClicked(0); |
1638 | e->accept(); | 1640 | e->accept(); |
1639 | } else | 1641 | } else |
1640 | e->ignore(); | 1642 | e->ignore(); |
1641 | break; | 1643 | break; |
1642 | default: | 1644 | default: |
1643 | e->ignore(); | 1645 | e->ignore(); |
1644 | } | 1646 | } |
1645 | 1647 | ||
1646 | if ( true ) { | 1648 | if ( true ) { |
1647 | if ( e->key() == Qt::Key_I ) { | 1649 | if ( e->key() == Qt::Key_I ) { |
1648 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1650 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1649 | if ( cn ) { | 1651 | if ( cn ) { |
1650 | mActiveItem = cn; | 1652 | mActiveItem = cn; |
1651 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1653 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1652 | if ( ci ){ | 1654 | if ( ci ){ |
1653 | showTodo(); | 1655 | showTodo(); |
1654 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1656 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1655 | if ( cn ) { | 1657 | if ( cn ) { |
1656 | mTodoListView->setCurrentItem ( cn ); | 1658 | mTodoListView->setCurrentItem ( cn ); |
1657 | mTodoListView->ensureItemVisible ( cn ); | 1659 | mTodoListView->ensureItemVisible ( cn ); |
1658 | } | 1660 | } |
1659 | 1661 | ||
1660 | } | 1662 | } |
1661 | } | 1663 | } |
1662 | e->accept(); | 1664 | e->accept(); |
1663 | 1665 | ||
1664 | } | 1666 | } |
1665 | 1667 | ||
1666 | } | 1668 | } |
1667 | 1669 | ||
1668 | } | 1670 | } |
1669 | void KOTodoView::updateTodo( Todo * t, int type ) | 1671 | void KOTodoView::updateTodo( Todo * t, int type ) |
1670 | { | 1672 | { |
1671 | if ( mBlockUpdate) | 1673 | if ( mBlockUpdate) |
1672 | return; | 1674 | return; |
1673 | 1675 | ||
1674 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1675 | itemIterator = mTodoMap.find(t); | 1677 | itemIterator = mTodoMap.find(t); |
1676 | if (itemIterator != mTodoMap.end()) { | 1678 | if (itemIterator != mTodoMap.end()) { |
1677 | (*itemIterator)->construct(); | 1679 | (*itemIterator)->construct(); |
1678 | } else { | 1680 | } else { |
1679 | if ( type == KOGlobals::EVENTADDED ) { | 1681 | if ( type == KOGlobals::EVENTADDED ) { |
1680 | insertTodoItem( t ); | 1682 | insertTodoItem( t ); |
1681 | } | 1683 | } |
1682 | } | 1684 | } |
1683 | 1685 | ||
1684 | } | 1686 | } |
1685 | 1687 | ||
1686 | void KOTodoView::todoModified(Todo * t , int p ) | 1688 | void KOTodoView::todoModified(Todo * t , int p ) |
1687 | { | 1689 | { |
1688 | mBlockUpdate = true; | 1690 | mBlockUpdate = true; |
1689 | emit todoModifiedSignal ( t, p ); | 1691 | emit todoModifiedSignal ( t, p ); |
1690 | mBlockUpdate = false; | 1692 | mBlockUpdate = false; |
1691 | } | 1693 | } |