author | zautrix <zautrix> | 2005-08-06 09:54:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-06 09:54:42 (UTC) |
commit | b841f4f2d54ac531c1f9ec88852d31307b9145f2 (patch) (unidiff) | |
tree | c334106e75e73bbc3fc33cd3c0d6480314a42774 /korganizer | |
parent | cd215c243d0636cabbc73006652b9b6783319de1 (diff) | |
download | kdepimpi-b841f4f2d54ac531c1f9ec88852d31307b9145f2.zip kdepimpi-b841f4f2d54ac531c1f9ec88852d31307b9145f2.tar.gz kdepimpi-b841f4f2d54ac531c1f9ec88852d31307b9145f2.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kotodoview.cpp | 46 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 2 |
2 files changed, 31 insertions, 17 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 00c2d97..27d755e 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -457,97 +457,98 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | |||
457 | } | 457 | } |
458 | e->ignore(); | 458 | e->ignore(); |
459 | } | 459 | } |
460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | QListView::contentsMouseReleaseEvent(e); | 462 | QListView::contentsMouseReleaseEvent(e); |
463 | mMousePressed = false; | 463 | mMousePressed = false; |
464 | } | 464 | } |
465 | 465 | ||
466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
467 | { | 467 | { |
468 | if (!e) return; | 468 | if (!e) return; |
469 | 469 | ||
470 | QPoint vp = contentsToViewport(e->pos()); | 470 | QPoint vp = contentsToViewport(e->pos()); |
471 | 471 | ||
472 | QListViewItem *item = itemAt(vp); | 472 | QListViewItem *item = itemAt(vp); |
473 | 473 | ||
474 | emit double_Clicked(item); | 474 | emit double_Clicked(item); |
475 | if (!item) return; | 475 | if (!item) return; |
476 | 476 | ||
477 | emit doubleClicked(item,vp,0); | 477 | emit doubleClicked(item,vp,0); |
478 | } | 478 | } |
479 | 479 | ||
480 | ///////////////////////////////////////////////////////////////////////////// | 480 | ///////////////////////////////////////////////////////////////////////////// |
481 | 481 | ||
482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
483 | QLineEdit(parent) | 483 | QLineEdit(parent) |
484 | { | 484 | { |
485 | setText(i18n("Click to add new Todo")); | 485 | setText(i18n("Click to add new Todo")); |
486 | } | 486 | } |
487 | 487 | ||
488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
489 | { | 489 | { |
490 | if ( text()==i18n("Click to add new Todo") ) | 490 | if ( text()==i18n("Click to add new Todo") ) |
491 | setText(""); | 491 | setText(""); |
492 | QLineEdit::focusInEvent(ev); | 492 | QLineEdit::focusInEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
496 | { | 496 | { |
497 | setText(i18n("Click to add new Todo")); | 497 | setText(i18n("Click to add new Todo")); |
498 | QLineEdit::focusOutEvent(ev); | 498 | QLineEdit::focusOutEvent(ev); |
499 | } | 499 | } |
500 | 500 | ||
501 | ///////////////////////////////////////////////////////////////////////////// | 501 | ///////////////////////////////////////////////////////////////////////////// |
502 | 502 | ||
503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
504 | KOrg::BaseView(calendar,parent,name) | 504 | KOrg::BaseView(calendar,parent,name) |
505 | { | 505 | { |
506 | mActiveItem = 0; | ||
506 | mCategoryPopupMenu = 0; | 507 | mCategoryPopupMenu = 0; |
507 | mPendingUpdateBeforeRepaint = false; | 508 | mPendingUpdateBeforeRepaint = false; |
508 | isFlatDisplay = false; | 509 | isFlatDisplay = false; |
509 | mNavigator = 0; | 510 | mNavigator = 0; |
510 | QBoxLayout *topLayout = new QVBoxLayout(this); | 511 | QBoxLayout *topLayout = new QVBoxLayout(this); |
511 | mName = QString ( name ); | 512 | mName = QString ( name ); |
512 | mBlockUpdate = false; | 513 | mBlockUpdate = false; |
513 | mQuickBar = new QWidget( this ); | 514 | mQuickBar = new QWidget( this ); |
514 | topLayout->addWidget(mQuickBar); | 515 | topLayout->addWidget(mQuickBar); |
515 | 516 | ||
516 | mQuickAdd = new KOQuickTodo(mQuickBar); | 517 | mQuickAdd = new KOQuickTodo(mQuickBar); |
517 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 518 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
518 | quickLayout->addWidget( mQuickAdd ); | 519 | quickLayout->addWidget( mQuickAdd ); |
519 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 520 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
520 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 521 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
521 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 522 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
522 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 523 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
523 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 524 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
524 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 525 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
525 | 526 | ||
526 | int fixwid = mQuickAdd->sizeHint().height(); | 527 | int fixwid = mQuickAdd->sizeHint().height(); |
527 | int fixhei = fixwid; | 528 | int fixhei = fixwid; |
528 | if ( QApplication::desktop()->width() > 800 ) | 529 | if ( QApplication::desktop()->width() > 800 ) |
529 | fixwid = (fixwid*3)/2; | 530 | fixwid = (fixwid*3)/2; |
530 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 531 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
531 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 532 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
532 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 533 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
533 | s_done->setPixmap( SmallIcon("greenhook16")); | 534 | s_done->setPixmap( SmallIcon("greenhook16")); |
534 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 535 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
535 | s_run->setPixmap( SmallIcon("ko16old")); | 536 | s_run->setPixmap( SmallIcon("ko16old")); |
536 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 537 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
537 | 538 | ||
538 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 539 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
539 | 540 | ||
540 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); | 541 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); |
541 | mNewSubBut->setEnabled( false ); | 542 | mNewSubBut->setEnabled( false ); |
542 | flat->setFixedWidth( fixwid ); | 543 | flat->setFixedWidth( fixwid ); |
543 | s_done->setFixedWidth( fixwid ); | 544 | s_done->setFixedWidth( fixwid ); |
544 | allopen->setFixedWidth( fixwid ); | 545 | allopen->setFixedWidth( fixwid ); |
545 | allclose->setFixedWidth( fixwid ); | 546 | allclose->setFixedWidth( fixwid ); |
546 | s_run->setFixedWidth( fixwid ); | 547 | s_run->setFixedWidth( fixwid ); |
547 | 548 | ||
548 | flat->setFixedHeight(fixhei ); | 549 | flat->setFixedHeight(fixhei ); |
549 | s_done->setFixedHeight(fixhei ); | 550 | s_done->setFixedHeight(fixhei ); |
550 | allopen->setFixedHeight(fixhei ); | 551 | allopen->setFixedHeight(fixhei ); |
551 | allclose->setFixedHeight(fixhei ); | 552 | allclose->setFixedHeight(fixhei ); |
552 | s_run->setFixedHeight(fixhei ); | 553 | s_run->setFixedHeight(fixhei ); |
553 | mNewSubBut->setFixedHeight(fixhei ); | 554 | mNewSubBut->setFixedHeight(fixhei ); |
@@ -762,154 +763,163 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
762 | } | 763 | } |
763 | 764 | ||
764 | KOTodoView::~KOTodoView() | 765 | KOTodoView::~KOTodoView() |
765 | { | 766 | { |
766 | 767 | ||
767 | #if QT_VERSION >= 0x030000 | 768 | #if QT_VERSION >= 0x030000 |
768 | 769 | ||
769 | #else | 770 | #else |
770 | delete mKOTodoViewWhatsThis; | 771 | delete mKOTodoViewWhatsThis; |
771 | #endif | 772 | #endif |
772 | 773 | ||
773 | delete mDocPrefs; | 774 | delete mDocPrefs; |
774 | } | 775 | } |
775 | QString KOTodoView::getWhatsThisText(QPoint p) | 776 | QString KOTodoView::getWhatsThisText(QPoint p) |
776 | { | 777 | { |
777 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 778 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
778 | if ( item ) | 779 | if ( item ) |
779 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 780 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
780 | KOPrefs::instance()->mWTshowDetails, | 781 | KOPrefs::instance()->mWTshowDetails, |
781 | KOPrefs::instance()->mWTshowCreated, | 782 | KOPrefs::instance()->mWTshowCreated, |
782 | KOPrefs::instance()->mWTshowChanged); | 783 | KOPrefs::instance()->mWTshowChanged); |
783 | return i18n("That is the todo view" ); | 784 | return i18n("That is the todo view" ); |
784 | 785 | ||
785 | } | 786 | } |
786 | 787 | ||
787 | void KOTodoView::jumpToDate () | 788 | void KOTodoView::jumpToDate () |
788 | { | 789 | { |
789 | // if (mActiveItem) { | 790 | // if (mActiveItem) { |
790 | // mActiveItem->todo()); | 791 | // mActiveItem->todo()); |
791 | // if ( mActiveItem->todo()->hasDueDate() ) | 792 | // if ( mActiveItem->todo()->hasDueDate() ) |
792 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 793 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
793 | } | 794 | } |
794 | void KOTodoView::paintNeeded() | 795 | void KOTodoView::paintNeeded() |
795 | { | 796 | { |
796 | if ( mPendingUpdateBeforeRepaint ) { | 797 | if ( mPendingUpdateBeforeRepaint ) { |
797 | updateView(); | 798 | updateView(); |
798 | mPendingUpdateBeforeRepaint = false; | 799 | mPendingUpdateBeforeRepaint = false; |
799 | } | 800 | } |
800 | } | 801 | } |
801 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 802 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
802 | { | 803 | { |
803 | if ( mPendingUpdateBeforeRepaint ) { | 804 | if ( mPendingUpdateBeforeRepaint ) { |
804 | updateView(); | 805 | updateView(); |
805 | mPendingUpdateBeforeRepaint = false; | 806 | mPendingUpdateBeforeRepaint = false; |
806 | } | 807 | } |
807 | KOrg::BaseView::paintEvent( pevent); | 808 | KOrg::BaseView::paintEvent( pevent); |
808 | } | 809 | } |
809 | 810 | ||
811 | void KOTodoView::clearList( bool saveCurrentItem ) // default true | ||
812 | { | ||
813 | if ( mTodoListView->childCount() ) { | ||
814 | if ( saveCurrentItem ) | ||
815 | storeCurrentItem(); | ||
816 | mTodoListView->clear(); | ||
817 | mTodoMap.clear(); | ||
818 | } | ||
819 | } | ||
810 | void KOTodoView::updateView() | 820 | void KOTodoView::updateView() |
811 | { | 821 | { |
822 | mActiveItem = 0; | ||
812 | pendingSubtodo = 0; | 823 | pendingSubtodo = 0; |
813 | if ( mBlockUpdate ) { | 824 | if ( mBlockUpdate ) { |
814 | return; | 825 | return; |
815 | } | 826 | } |
816 | if ( !isVisible() ) { | 827 | if ( !isVisible() ) { |
817 | mPendingUpdateBeforeRepaint = true; | 828 | clearList (); |
818 | return; | 829 | mPendingUpdateBeforeRepaint = true; |
830 | return; | ||
819 | } | 831 | } |
820 | //qDebug("KOTodoView::updateView() %x", this); | 832 | //qDebug("KOTodoView::updateView() %x", this); |
821 | if ( isFlatDisplay ) { | 833 | if ( isFlatDisplay ) { |
822 | displayAllFlat(); | 834 | displayAllFlat(); |
823 | return; | 835 | return; |
824 | } | 836 | } |
825 | storeCurrentItem(); | ||
826 | //qDebug("update "); | 837 | //qDebug("update "); |
827 | // kdDebug() << "KOTodoView::updateView()" << endl; | 838 | // kdDebug() << "KOTodoView::updateView()" << endl; |
828 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 839 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
829 | 840 | ||
830 | 841 | clearList (); | |
831 | mTodoListView->clear(); | 842 | |
832 | if ( mName == "todolistsmall" ) { | 843 | if ( mName == "todolistsmall" ) { |
833 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 844 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
834 | int ps = fo.pointSize() -2; | 845 | int ps = fo.pointSize() -2; |
835 | if ( ps > 12 ) | 846 | if ( ps > 12 ) |
836 | ps -= 2; | 847 | ps -= 2; |
837 | fo.setPointSize( ps ); | 848 | fo.setPointSize( ps ); |
838 | } | 849 | } |
839 | } | 850 | } |
840 | 851 | ||
841 | mTodoListView->setFont( fo ); | 852 | mTodoListView->setFont( fo ); |
842 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 853 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
843 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 854 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
844 | QPtrList<Todo> todoList = calendar()->todos(); | 855 | QPtrList<Todo> todoList = calendar()->todos(); |
845 | 856 | ||
846 | /* | 857 | /* |
847 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 858 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
848 | Event *t; | 859 | Event *t; |
849 | for(t = todoList.first(); t; t = todoList.next()) { | 860 | for(t = todoList.first(); t; t = todoList.next()) { |
850 | kdDebug() << " " << t->getSummary() << endl; | 861 | kdDebug() << " " << t->getSummary() << endl; |
851 | 862 | ||
852 | if (t->getRelatedTo()) { | 863 | if (t->getRelatedTo()) { |
853 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 864 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
854 | } | 865 | } |
855 | 866 | ||
856 | QPtrList<Event> l = t->getRelations(); | 867 | QPtrList<Event> l = t->getRelations(); |
857 | Event *c; | 868 | Event *c; |
858 | for(c=l.first();c;c=l.next()) { | 869 | for(c=l.first();c;c=l.next()) { |
859 | kdDebug() << " - relation: " << c->getSummary() << endl; | 870 | kdDebug() << " - relation: " << c->getSummary() << endl; |
860 | } | 871 | } |
861 | } | 872 | } |
862 | */ | 873 | */ |
863 | 874 | ||
864 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 875 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
865 | // specific order of events. That means that we have to generate parent items | 876 | // specific order of events. That means that we have to generate parent items |
866 | // recursively for proper hierarchical display of Todos. | 877 | // recursively for proper hierarchical display of Todos. |
867 | mTodoMap.clear(); | ||
868 | Todo *todo; | 878 | Todo *todo; |
869 | todo = todoList.first();// todo; todo = todoList.next()) { | 879 | todo = todoList.first();// todo; todo = todoList.next()) { |
870 | while ( todo ) { | 880 | while ( todo ) { |
871 | bool next = true; | 881 | bool next = true; |
872 | // qDebug("todo %s ", todo->summary().latin1()); | 882 | // qDebug("todo %s ", todo->summary().latin1()); |
873 | Incidence *incidence = todo->relatedTo(); | 883 | Incidence *incidence = todo->relatedTo(); |
874 | while ( incidence ) { | 884 | while ( incidence ) { |
875 | if ( incidence->typeID() == todoID ) { | 885 | if ( incidence->typeID() == todoID ) { |
876 | //qDebug("related %s ",incidence->summary().latin1() ); | 886 | //qDebug("related %s ",incidence->summary().latin1() ); |
877 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 887 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
878 | //qDebug("related not found "); | 888 | //qDebug("related not found "); |
879 | todoList.remove( ); | 889 | todoList.remove( ); |
880 | todo = todoList.current(); | 890 | todo = todoList.current(); |
881 | next = false; | 891 | next = false; |
882 | incidence = 0; | 892 | incidence = 0; |
883 | 893 | ||
884 | } else { | 894 | } else { |
885 | //qDebug("related found "); | 895 | //qDebug("related found "); |
886 | incidence = incidence->relatedTo(); | 896 | incidence = incidence->relatedTo(); |
887 | } | 897 | } |
888 | } else | 898 | } else |
889 | incidence = 0; | 899 | incidence = 0; |
890 | } | 900 | } |
891 | if ( next ) | 901 | if ( next ) |
892 | todo = todoList.next(); | 902 | todo = todoList.next(); |
893 | } | 903 | } |
894 | 904 | ||
895 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 905 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
896 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 906 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
897 | { | 907 | { |
898 | insertTodoItem(todo); | 908 | insertTodoItem(todo); |
899 | } | 909 | } |
900 | } | 910 | } |
901 | // Restore opened/closed state | 911 | // Restore opened/closed state |
902 | mTodoListView->blockSignals( true ); | 912 | mTodoListView->blockSignals( true ); |
903 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 913 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
904 | mTodoListView->blockSignals( false ); | 914 | mTodoListView->blockSignals( false ); |
905 | resetCurrentItem(); | 915 | resetCurrentItem(); |
906 | } | 916 | } |
907 | 917 | ||
908 | void KOTodoView::storeCurrentItem() | 918 | void KOTodoView::storeCurrentItem() |
909 | { | 919 | { |
910 | mCurItem = 0; | 920 | mCurItem = 0; |
911 | mCurItemRootParent = 0; | 921 | mCurItemRootParent = 0; |
912 | mCurItemParent = 0; | 922 | mCurItemParent = 0; |
913 | mCurItemAbove = 0; | 923 | mCurItemAbove = 0; |
914 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 924 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
915 | if (mActiveItem) { | 925 | if (mActiveItem) { |
@@ -929,97 +939,98 @@ void KOTodoView::resetCurrentItem() | |||
929 | { | 939 | { |
930 | //mTodoListView->setFocus(); | 940 | //mTodoListView->setFocus(); |
931 | KOTodoViewItem* foundItem = 0; | 941 | KOTodoViewItem* foundItem = 0; |
932 | KOTodoViewItem* foundItemRoot = 0; | 942 | KOTodoViewItem* foundItemRoot = 0; |
933 | KOTodoViewItem* foundItemParent = 0; | 943 | KOTodoViewItem* foundItemParent = 0; |
934 | KOTodoViewItem* foundItemAbove = 0; | 944 | KOTodoViewItem* foundItemAbove = 0; |
935 | if ( mTodoListView->firstChild () ) { | 945 | if ( mTodoListView->firstChild () ) { |
936 | if ( mCurItem ) { | 946 | if ( mCurItem ) { |
937 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 947 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
938 | while ( item ) { | 948 | while ( item ) { |
939 | if ( item->todo() == mCurItem ) { | 949 | if ( item->todo() == mCurItem ) { |
940 | foundItem = item; | 950 | foundItem = item; |
941 | break; | 951 | break; |
942 | } else if ( item->todo() == mCurItemAbove ) { | 952 | } else if ( item->todo() == mCurItemAbove ) { |
943 | foundItemAbove = item; | 953 | foundItemAbove = item; |
944 | 954 | ||
945 | } | 955 | } |
946 | if ( item->todo() == mCurItemRootParent ) { | 956 | if ( item->todo() == mCurItemRootParent ) { |
947 | foundItemRoot = item; | 957 | foundItemRoot = item; |
948 | } | 958 | } |
949 | if ( item->todo() == mCurItemParent ) { | 959 | if ( item->todo() == mCurItemParent ) { |
950 | foundItemParent = item; | 960 | foundItemParent = item; |
951 | } | 961 | } |
952 | item = (KOTodoViewItem*)item->itemBelow(); | 962 | item = (KOTodoViewItem*)item->itemBelow(); |
953 | } | 963 | } |
954 | if ( ! foundItem ) { | 964 | if ( ! foundItem ) { |
955 | if ( foundItemParent ) { | 965 | if ( foundItemParent ) { |
956 | foundItem = foundItemParent; | 966 | foundItem = foundItemParent; |
957 | } else { | 967 | } else { |
958 | if ( foundItemRoot ) | 968 | if ( foundItemRoot ) |
959 | foundItem = foundItemRoot; | 969 | foundItem = foundItemRoot; |
960 | else | 970 | else |
961 | foundItem = foundItemAbove; | 971 | foundItem = foundItemAbove; |
962 | } | 972 | } |
963 | } | 973 | } |
964 | } | 974 | } |
965 | if ( foundItem ) { | 975 | if ( foundItem ) { |
966 | mTodoListView->setSelected ( foundItem, true ); | 976 | mTodoListView->setSelected ( foundItem, true ); |
967 | mTodoListView->setCurrentItem( foundItem ); | 977 | mTodoListView->setCurrentItem( foundItem ); |
968 | mTodoListView->ensureItemVisible( foundItem ); | 978 | mTodoListView->ensureItemVisible( foundItem ); |
969 | } else { | 979 | } else { |
970 | if ( mTodoListView->firstChild () ) { | 980 | if ( mTodoListView->firstChild () ) { |
971 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 981 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
972 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 982 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
973 | } | 983 | } |
974 | } | 984 | } |
975 | } | 985 | } |
976 | processSelectionChange(); | 986 | processSelectionChange(); |
977 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 987 | if ( mName != "todolistsmall" ) |
988 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | ||
978 | } | 989 | } |
979 | void KOTodoView::resetFocusToList() | 990 | void KOTodoView::resetFocusToList() |
980 | { | 991 | { |
981 | topLevelWidget()->setActiveWindow(); | 992 | topLevelWidget()->setActiveWindow(); |
982 | mTodoListView->setFocus(); | 993 | mTodoListView->setFocus(); |
983 | } | 994 | } |
984 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 995 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
985 | bool KOTodoView::checkTodo( Todo * todo ) | 996 | bool KOTodoView::checkTodo( Todo * todo ) |
986 | { | 997 | { |
987 | 998 | ||
988 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 999 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
989 | return false; | 1000 | return false; |
990 | if ( !todo->isCompleted() ) { | 1001 | if ( !todo->isCompleted() ) { |
991 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 1002 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
992 | return true; | 1003 | return true; |
993 | } | 1004 | } |
994 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 1005 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
995 | if ( todo->hasStartDate() ) | 1006 | if ( todo->hasStartDate() ) |
996 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 1007 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
997 | return false; | 1008 | return false; |
998 | if ( todo->hasDueDate() ) | 1009 | if ( todo->hasDueDate() ) |
999 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 1010 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
1000 | return false; | 1011 | return false; |
1001 | } | 1012 | } |
1002 | return true; | 1013 | return true; |
1003 | } | 1014 | } |
1004 | 1015 | ||
1005 | void KOTodoView::restoreItemState( QListViewItem *item ) | 1016 | void KOTodoView::restoreItemState( QListViewItem *item ) |
1006 | { | 1017 | { |
1007 | pendingSubtodo = 0; | 1018 | pendingSubtodo = 0; |
1008 | while( item ) { | 1019 | while( item ) { |
1009 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1020 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1010 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 1021 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
1011 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 1022 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
1012 | item = item->nextSibling(); | 1023 | item = item->nextSibling(); |
1013 | } | 1024 | } |
1014 | } | 1025 | } |
1015 | 1026 | ||
1016 | 1027 | ||
1017 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1028 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
1018 | KOTodoView::insertTodoItem(Todo *todo) | 1029 | KOTodoView::insertTodoItem(Todo *todo) |
1019 | { | 1030 | { |
1020 | 1031 | ||
1021 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1032 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1022 | // TODO: Check, if dynmaic cast is necessary | 1033 | // TODO: Check, if dynmaic cast is necessary |
1023 | 1034 | ||
1024 | pendingSubtodo = 0; | 1035 | pendingSubtodo = 0; |
1025 | Incidence *incidence = todo->relatedTo(); | 1036 | Incidence *incidence = todo->relatedTo(); |
@@ -1055,102 +1066,104 @@ void KOTodoView::updateConfig() | |||
1055 | } | 1066 | } |
1056 | 1067 | ||
1057 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1068 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1058 | { | 1069 | { |
1059 | QPtrList<Incidence> selected; | 1070 | QPtrList<Incidence> selected; |
1060 | 1071 | ||
1061 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1062 | // if (!item) item = mActiveItem; | 1073 | // if (!item) item = mActiveItem; |
1063 | if (item) selected.append(item->todo()); | 1074 | if (item) selected.append(item->todo()); |
1064 | 1075 | ||
1065 | return selected; | 1076 | return selected; |
1066 | } | 1077 | } |
1067 | 1078 | ||
1068 | QPtrList<Todo> KOTodoView::selectedTodos() | 1079 | QPtrList<Todo> KOTodoView::selectedTodos() |
1069 | { | 1080 | { |
1070 | QPtrList<Todo> selected; | 1081 | QPtrList<Todo> selected; |
1071 | 1082 | ||
1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1083 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1073 | // if (!item) item = mActiveItem; | 1084 | // if (!item) item = mActiveItem; |
1074 | if (item) selected.append(item->todo()); | 1085 | if (item) selected.append(item->todo()); |
1075 | 1086 | ||
1076 | return selected; | 1087 | return selected; |
1077 | } | 1088 | } |
1078 | 1089 | ||
1079 | void KOTodoView::changeEventDisplay(Event *, int) | 1090 | void KOTodoView::changeEventDisplay(Event *, int) |
1080 | { | 1091 | { |
1081 | updateView(); | 1092 | updateView(); |
1082 | } | 1093 | } |
1083 | 1094 | ||
1084 | void KOTodoView::showDates(const QDate &, const QDate &) | 1095 | void KOTodoView::showDates(const QDate &, const QDate &) |
1085 | { | 1096 | { |
1086 | } | 1097 | } |
1087 | 1098 | ||
1088 | void KOTodoView::showEvents(QPtrList<Event>) | 1099 | void KOTodoView::showEvents(QPtrList<Event>) |
1089 | { | 1100 | { |
1090 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1101 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1091 | } | 1102 | } |
1092 | 1103 | ||
1093 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1104 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1094 | const QDate &td) | 1105 | const QDate &td) |
1095 | { | 1106 | { |
1096 | #ifndef KORG_NOPRINTER | 1107 | #ifndef KORG_NOPRINTER |
1097 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1108 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1098 | #endif | 1109 | #endif |
1099 | } | 1110 | } |
1100 | 1111 | ||
1101 | void KOTodoView::editItem(QListViewItem *item ) | 1112 | void KOTodoView::editItem(QListViewItem *item ) |
1102 | { | 1113 | { |
1103 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1114 | if ( item ) |
1115 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | ||
1104 | } | 1116 | } |
1105 | 1117 | ||
1106 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1118 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1107 | { | 1119 | { |
1108 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1120 | if ( item ) |
1121 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | ||
1109 | } | 1122 | } |
1110 | 1123 | ||
1111 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1124 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1112 | { | 1125 | { |
1113 | pendingSubtodo = 0; | 1126 | pendingSubtodo = 0; |
1114 | mActiveItem = (KOTodoViewItem *)item; | 1127 | mActiveItem = (KOTodoViewItem *)item; |
1115 | if (item) { | 1128 | if (item) { |
1116 | switch (column){ | 1129 | switch (column){ |
1117 | case 1: | 1130 | case 1: |
1118 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1131 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1119 | case 2: | 1132 | case 2: |
1120 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1133 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1121 | case 3: | 1134 | case 3: |
1122 | moveTodo(); | 1135 | moveTodo(); |
1123 | break; | 1136 | break; |
1124 | case 7: | 1137 | case 7: |
1125 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1138 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1126 | case 8: | 1139 | case 8: |
1127 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1140 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1128 | default: | 1141 | default: |
1129 | mItemPopupMenu->popup(QCursor::pos()); | 1142 | mItemPopupMenu->popup(QCursor::pos()); |
1130 | } | 1143 | } |
1131 | } else mPopupMenu->popup(QCursor::pos()); | 1144 | } else mPopupMenu->popup(QCursor::pos()); |
1132 | } | 1145 | } |
1133 | void KOTodoView::newTodo() | 1146 | void KOTodoView::newTodo() |
1134 | { | 1147 | { |
1135 | emit newTodoSignal(); | 1148 | emit newTodoSignal(); |
1136 | } | 1149 | } |
1137 | 1150 | ||
1138 | void KOTodoView::newSubTodo() | 1151 | void KOTodoView::newSubTodo() |
1139 | { | 1152 | { |
1140 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1153 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1141 | if (mActiveItem) { | 1154 | if (mActiveItem) { |
1142 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { | 1155 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { |
1143 | addQuickTodoPar( mActiveItem->todo()); | 1156 | addQuickTodoPar( mActiveItem->todo()); |
1144 | } else | 1157 | } else |
1145 | emit newSubTodoSignal(mActiveItem->todo()); | 1158 | emit newSubTodoSignal(mActiveItem->todo()); |
1146 | } | 1159 | } |
1147 | } | 1160 | } |
1148 | void KOTodoView::unparentTodo() | 1161 | void KOTodoView::unparentTodo() |
1149 | { | 1162 | { |
1150 | if (mActiveItem) { | 1163 | if (mActiveItem) { |
1151 | emit unparentTodoSignal(mActiveItem->todo()); | 1164 | emit unparentTodoSignal(mActiveItem->todo()); |
1152 | } | 1165 | } |
1153 | } | 1166 | } |
1154 | 1167 | ||
1155 | void KOTodoView::reparentTodo() | 1168 | void KOTodoView::reparentTodo() |
1156 | { | 1169 | { |
@@ -1312,114 +1325,114 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) | |||
1312 | } else { | 1325 | } else { |
1313 | if ( row == 1 ) { | 1326 | if ( row == 1 ) { |
1314 | mActiveItem = (KOTodoViewItem *) item; | 1327 | mActiveItem = (KOTodoViewItem *) item; |
1315 | newSubTodo(); | 1328 | newSubTodo(); |
1316 | return; | 1329 | return; |
1317 | } | 1330 | } |
1318 | if ( row == 5 || row == 6 || row == 2) { | 1331 | if ( row == 5 || row == 6 || row == 2) { |
1319 | mActiveItem = (KOTodoViewItem *) item; | 1332 | mActiveItem = (KOTodoViewItem *) item; |
1320 | Todo * t = mActiveItem->todo(); | 1333 | Todo * t = mActiveItem->todo(); |
1321 | if ( t->isRunning() ) { | 1334 | if ( t->isRunning() ) { |
1322 | if ( t->runTime() < 15) { | 1335 | if ( t->runTime() < 15) { |
1323 | t->stopRunning(); | 1336 | t->stopRunning(); |
1324 | mActiveItem->construct(); | 1337 | mActiveItem->construct(); |
1325 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1338 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1326 | return; | 1339 | return; |
1327 | } | 1340 | } |
1328 | else | 1341 | else |
1329 | toggleRunningItem(); | 1342 | toggleRunningItem(); |
1330 | return; | 1343 | return; |
1331 | } else { | 1344 | } else { |
1332 | t->setRunning( true ); | 1345 | t->setRunning( true ); |
1333 | mActiveItem->construct(); | 1346 | mActiveItem->construct(); |
1334 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1347 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1335 | return; | 1348 | return; |
1336 | } | 1349 | } |
1337 | } | 1350 | } |
1338 | } | 1351 | } |
1339 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1352 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1340 | editItem( item ); | 1353 | editItem( item ); |
1341 | else | 1354 | else |
1342 | showItem( item , QPoint(), 0 ); | 1355 | showItem( item , QPoint(), 0 ); |
1343 | } | 1356 | } |
1344 | void KOTodoView::toggleRunningItem() | 1357 | void KOTodoView::toggleRunningItem() |
1345 | { | 1358 | { |
1346 | // qDebug("KOTodoView::toggleRunning() "); | 1359 | // qDebug("KOTodoView::toggleRunning() "); |
1347 | if ( ! mActiveItem ) | 1360 | if ( ! mActiveItem ) |
1348 | return; | 1361 | return; |
1349 | Todo * t = mActiveItem->todo(); | 1362 | Todo * t = mActiveItem->todo(); |
1350 | if ( t->isRunning() ) { | 1363 | if ( t->isRunning() ) { |
1351 | KOStopTodoPrefs tp ( t, this ); | 1364 | KOStopTodoPrefs tp ( t, this ); |
1352 | if (QApplication::desktop()->width() <= 800 ){ | 1365 | if (QApplication::desktop()->width() <= 800 ){ |
1353 | int wid = tp.width(); | 1366 | int wid = tp.width(); |
1354 | int hei = tp.height(); | 1367 | int hei = tp.height(); |
1355 | int xx = (QApplication::desktop()->width()-wid)/2; | 1368 | int xx = (QApplication::desktop()->width()-wid)/2; |
1356 | int yy = (QApplication::desktop()->height()-hei)/2; | 1369 | int yy = (QApplication::desktop()->height()-hei)/2; |
1357 | tp.setGeometry( xx,yy,wid,hei ); | 1370 | tp.setGeometry( xx,yy,wid,hei ); |
1358 | } | 1371 | } |
1359 | tp.exec(); | 1372 | tp.exec(); |
1360 | updateTodo ( t, 0 ); | 1373 | updateTodo ( t, KOGlobals::EVENTEDITED ); |
1361 | } else { | 1374 | } else { |
1362 | KOStartTodoPrefs tp ( t->summary(), this ); | 1375 | KOStartTodoPrefs tp ( t->summary(), this ); |
1363 | if (QApplication::desktop()->width() <= 800 ){ | 1376 | if (QApplication::desktop()->width() <= 800 ){ |
1364 | int wid = tp.width(); | 1377 | int wid = tp.width(); |
1365 | int hei = tp.height(); | 1378 | int hei = tp.height(); |
1366 | int xx = (QApplication::desktop()->width()-wid)/2; | 1379 | int xx = (QApplication::desktop()->width()-wid)/2; |
1367 | int yy = (QApplication::desktop()->height()-hei)/2; | 1380 | int yy = (QApplication::desktop()->height()-hei)/2; |
1368 | tp.setGeometry( xx,yy,wid,hei ); | 1381 | tp.setGeometry( xx,yy,wid,hei ); |
1369 | } | 1382 | } |
1370 | if ( !tp.exec() ) return; | 1383 | if ( !tp.exec() ) return; |
1371 | if ( tp.stopAll() ) { | 1384 | if ( tp.stopAll() ) { |
1372 | mCalendar->stopAllTodos(); | 1385 | mCalendar->stopAllTodos(); |
1373 | t->setRunning( true ); | 1386 | t->setRunning( true ); |
1374 | updateView(); | 1387 | updateView(); |
1375 | } else { | 1388 | } else { |
1376 | t->setRunning( true ); | 1389 | t->setRunning( true ); |
1377 | updateTodo ( t, 0 ); | 1390 | updateTodo ( t, KOGlobals::EVENTEDITED ); |
1378 | } | 1391 | } |
1379 | } | 1392 | } |
1380 | } | 1393 | } |
1381 | 1394 | ||
1382 | void KOTodoView::itemClicked(QListViewItem *item) | 1395 | void KOTodoView::itemClicked(QListViewItem *item) |
1383 | { | 1396 | { |
1384 | //qDebug("KOTodoView::itemClicked %d", item); | 1397 | //qDebug("KOTodoView::itemClicked %d", item); |
1385 | if (!item) { | 1398 | if (!item) { |
1386 | if ( pendingSubtodo != 0 ) { | 1399 | if ( pendingSubtodo != 0 ) { |
1387 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1400 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1388 | } | 1401 | } |
1389 | pendingSubtodo = 0; | 1402 | pendingSubtodo = 0; |
1390 | return; | 1403 | return; |
1391 | } | 1404 | } |
1392 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1405 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1393 | if ( pendingSubtodo != 0 ) { | 1406 | if ( pendingSubtodo != 0 ) { |
1394 | bool allowReparent = true; | 1407 | bool allowReparent = true; |
1395 | QListViewItem *par = item; | 1408 | QListViewItem *par = item; |
1396 | while ( par ) { | 1409 | while ( par ) { |
1397 | if ( par == pendingSubtodo ) { | 1410 | if ( par == pendingSubtodo ) { |
1398 | allowReparent = false; | 1411 | allowReparent = false; |
1399 | break; | 1412 | break; |
1400 | } | 1413 | } |
1401 | par = par->parent(); | 1414 | par = par->parent(); |
1402 | } | 1415 | } |
1403 | if ( !allowReparent ) { | 1416 | if ( !allowReparent ) { |
1404 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1417 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1405 | pendingSubtodo = 0; | 1418 | pendingSubtodo = 0; |
1406 | } else { | 1419 | } else { |
1407 | Todo* newParent = todoItem->todo(); | 1420 | Todo* newParent = todoItem->todo(); |
1408 | Todo* newSub = pendingSubtodo->todo(); | 1421 | Todo* newSub = pendingSubtodo->todo(); |
1409 | pendingSubtodo = 0; | 1422 | pendingSubtodo = 0; |
1410 | emit reparentTodoSignal( newParent,newSub ); | 1423 | emit reparentTodoSignal( newParent,newSub ); |
1411 | return; | 1424 | return; |
1412 | } | 1425 | } |
1413 | } | 1426 | } |
1414 | 1427 | ||
1415 | } | 1428 | } |
1416 | 1429 | ||
1417 | void KOTodoView::setDocumentId( const QString &id ) | 1430 | void KOTodoView::setDocumentId( const QString &id ) |
1418 | { | 1431 | { |
1419 | 1432 | ||
1420 | mDocPrefs->setDoc( id ); | 1433 | mDocPrefs->setDoc( id ); |
1421 | } | 1434 | } |
1422 | 1435 | ||
1423 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1436 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1424 | { | 1437 | { |
1425 | if (!item) return; | 1438 | if (!item) return; |
@@ -1460,106 +1473,106 @@ void KOTodoView::processSelectionChange() | |||
1460 | void KOTodoView::modified(bool b) | 1473 | void KOTodoView::modified(bool b) |
1461 | { | 1474 | { |
1462 | emit isModified(b); | 1475 | emit isModified(b); |
1463 | } | 1476 | } |
1464 | void KOTodoView::setTodoModified( Todo* todo ) | 1477 | void KOTodoView::setTodoModified( Todo* todo ) |
1465 | { | 1478 | { |
1466 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1479 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1467 | } | 1480 | } |
1468 | void KOTodoView::clearSelection() | 1481 | void KOTodoView::clearSelection() |
1469 | { | 1482 | { |
1470 | mTodoListView->selectAll( false ); | 1483 | mTodoListView->selectAll( false ); |
1471 | } | 1484 | } |
1472 | void KOTodoView::setAllOpen() | 1485 | void KOTodoView::setAllOpen() |
1473 | { | 1486 | { |
1474 | if ( isFlatDisplay ) { | 1487 | if ( isFlatDisplay ) { |
1475 | isFlatDisplay = false; | 1488 | isFlatDisplay = false; |
1476 | mPopupMenu->setItemChecked( 8,false ); | 1489 | mPopupMenu->setItemChecked( 8,false ); |
1477 | updateView(); | 1490 | updateView(); |
1478 | } else { | 1491 | } else { |
1479 | storeCurrentItem(); | 1492 | storeCurrentItem(); |
1480 | } | 1493 | } |
1481 | setOpen(mTodoListView->firstChild(), true); | 1494 | setOpen(mTodoListView->firstChild(), true); |
1482 | resetCurrentItem(); | 1495 | resetCurrentItem(); |
1483 | } | 1496 | } |
1484 | void KOTodoView::setAllClose() | 1497 | void KOTodoView::setAllClose() |
1485 | { | 1498 | { |
1486 | if ( isFlatDisplay ) { | 1499 | if ( isFlatDisplay ) { |
1487 | isFlatDisplay = false; | 1500 | isFlatDisplay = false; |
1488 | mPopupMenu->setItemChecked( 8,false ); | 1501 | mPopupMenu->setItemChecked( 8,false ); |
1489 | updateView(); | 1502 | updateView(); |
1490 | } else { | 1503 | } else { |
1491 | storeCurrentItem(); | 1504 | storeCurrentItem(); |
1492 | } | 1505 | } |
1493 | setOpen(mTodoListView->firstChild(), false); | 1506 | setOpen(mTodoListView->firstChild(), false); |
1494 | resetCurrentItem(); | 1507 | resetCurrentItem(); |
1495 | } | 1508 | } |
1496 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1509 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1497 | { | 1510 | { |
1498 | 1511 | ||
1499 | while ( item ) { | 1512 | while ( item ) { |
1500 | setOpen( item->firstChild(), setOpenI ); | 1513 | setOpen( item->firstChild(), setOpenI ); |
1501 | item->setOpen( setOpenI ); | 1514 | item->setOpen( setOpenI ); |
1502 | item = item->nextSibling(); | 1515 | item = item->nextSibling(); |
1503 | } | 1516 | } |
1504 | } | 1517 | } |
1505 | 1518 | ||
1506 | void KOTodoView::displayAllFlat() | 1519 | void KOTodoView::displayAllFlat() |
1507 | { | 1520 | { |
1508 | storeCurrentItem(); | 1521 | |
1522 | mActiveItem = 0; | ||
1509 | pendingSubtodo = 0; | 1523 | pendingSubtodo = 0; |
1510 | if ( mBlockUpdate ) { | 1524 | if ( mBlockUpdate ) { |
1511 | return; | 1525 | return; |
1512 | } | 1526 | } |
1527 | clearList (); | ||
1513 | mPopupMenu->setItemChecked( 8,true ); | 1528 | mPopupMenu->setItemChecked( 8,true ); |
1514 | isFlatDisplay = true; | 1529 | isFlatDisplay = true; |
1515 | QPtrList<Todo> todoList = calendar()->todos(); | 1530 | QPtrList<Todo> todoList = calendar()->todos(); |
1516 | mTodoMap.clear(); | ||
1517 | mTodoListView->clear(); | ||
1518 | Todo *todo; | 1531 | Todo *todo; |
1519 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1532 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1520 | if ( checkTodo( todo ) ) { | 1533 | if ( checkTodo( todo ) ) { |
1521 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1534 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1522 | mTodoMap.insert(todo,todoItem); | 1535 | mTodoMap.insert(todo,todoItem); |
1523 | } | 1536 | } |
1524 | } | 1537 | } |
1525 | resetCurrentItem(); | 1538 | resetCurrentItem(); |
1526 | } | 1539 | } |
1527 | 1540 | ||
1528 | void KOTodoView::setAllFlat() | 1541 | void KOTodoView::setAllFlat() |
1529 | { | 1542 | { |
1530 | if ( isFlatDisplay ) { | 1543 | if ( isFlatDisplay ) { |
1531 | isFlatDisplay = false; | 1544 | isFlatDisplay = false; |
1532 | mPopupMenu->setItemChecked( 8,false ); | 1545 | mPopupMenu->setItemChecked( 8,false ); |
1533 | updateView(); | 1546 | updateView(); |
1534 | return; | 1547 | return; |
1535 | } | 1548 | } |
1536 | displayAllFlat(); | 1549 | displayAllFlat(); |
1537 | } | 1550 | } |
1538 | 1551 | ||
1539 | void KOTodoView::purgeCompleted() | 1552 | void KOTodoView::purgeCompleted() |
1540 | { | 1553 | { |
1541 | emit purgeCompletedSignal(); | 1554 | emit purgeCompletedSignal(); |
1542 | 1555 | ||
1543 | } | 1556 | } |
1544 | void KOTodoView::toggleQuickTodo() | 1557 | void KOTodoView::toggleQuickTodo() |
1545 | { | 1558 | { |
1546 | if ( mQuickBar->isVisible() ) { | 1559 | if ( mQuickBar->isVisible() ) { |
1547 | mQuickBar->hide(); | 1560 | mQuickBar->hide(); |
1548 | KOPrefs::instance()->mEnableQuickTodo = false; | 1561 | KOPrefs::instance()->mEnableQuickTodo = false; |
1549 | } | 1562 | } |
1550 | else { | 1563 | else { |
1551 | mQuickBar->show(); | 1564 | mQuickBar->show(); |
1552 | KOPrefs::instance()->mEnableQuickTodo = true; | 1565 | KOPrefs::instance()->mEnableQuickTodo = true; |
1553 | } | 1566 | } |
1554 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1567 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1555 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1568 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1556 | } | 1569 | } |
1557 | 1570 | ||
1558 | void KOTodoView::toggleRunning() | 1571 | void KOTodoView::toggleRunning() |
1559 | { | 1572 | { |
1560 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1573 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1561 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1574 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1562 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1575 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1563 | updateView(); | 1576 | updateView(); |
1564 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 1577 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
1565 | topLevelWidget()->setCaption(i18n("Hide not Running")); | 1578 | topLevelWidget()->setCaption(i18n("Hide not Running")); |
@@ -1651,71 +1664,72 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e ) | |||
1651 | } | 1664 | } |
1652 | if ( e->state() == Qt::ShiftButton ) { | 1665 | if ( e->state() == Qt::ShiftButton ) { |
1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1666 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1654 | reparentTodo(); | 1667 | reparentTodo(); |
1655 | e->accept(); | 1668 | e->accept(); |
1656 | } else | 1669 | } else |
1657 | e->ignore(); | 1670 | e->ignore(); |
1658 | break; | 1671 | break; |
1659 | case Qt::Key_P: | 1672 | case Qt::Key_P: |
1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1673 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1674 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1662 | if ( pendingSubtodo ) | 1675 | if ( pendingSubtodo ) |
1663 | itemClicked(mActiveItem); | 1676 | itemClicked(mActiveItem); |
1664 | e->accept(); | 1677 | e->accept(); |
1665 | } else | 1678 | } else |
1666 | e->ignore(); | 1679 | e->ignore(); |
1667 | break; | 1680 | break; |
1668 | case Qt::Key_Escape: | 1681 | case Qt::Key_Escape: |
1669 | if ( pendingSubtodo ) { | 1682 | if ( pendingSubtodo ) { |
1670 | itemClicked(0); | 1683 | itemClicked(0); |
1671 | e->accept(); | 1684 | e->accept(); |
1672 | } else | 1685 | } else |
1673 | e->ignore(); | 1686 | e->ignore(); |
1674 | break; | 1687 | break; |
1675 | default: | 1688 | default: |
1676 | e->ignore(); | 1689 | e->ignore(); |
1677 | } | 1690 | } |
1678 | 1691 | ||
1679 | if ( true ) { | 1692 | if ( true ) { |
1680 | if ( e->key() == Qt::Key_I ) { | 1693 | if ( e->key() == Qt::Key_I ) { |
1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1694 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1682 | if ( cn ) { | 1695 | if ( cn ) { |
1683 | mActiveItem = cn; | 1696 | mActiveItem = cn; |
1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1697 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1685 | if ( ci ){ | 1698 | if ( ci ){ |
1686 | showTodo(); | 1699 | showTodo(); |
1687 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1700 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1688 | if ( cn ) { | 1701 | if ( cn ) { |
1689 | mTodoListView->setCurrentItem ( cn ); | 1702 | mTodoListView->setCurrentItem ( cn ); |
1690 | mTodoListView->ensureItemVisible ( cn ); | 1703 | mTodoListView->ensureItemVisible ( cn ); |
1691 | } | 1704 | } |
1692 | 1705 | ||
1693 | } | 1706 | } |
1694 | } | 1707 | } |
1695 | e->accept(); | 1708 | e->accept(); |
1696 | } | 1709 | } |
1697 | } | 1710 | } |
1698 | } | 1711 | } |
1712 | |||
1699 | void KOTodoView::updateTodo( Todo * t, int type ) | 1713 | void KOTodoView::updateTodo( Todo * t, int type ) |
1700 | { | 1714 | { |
1701 | if ( mBlockUpdate) | 1715 | if ( mBlockUpdate ) |
1702 | return; | 1716 | return; |
1703 | 1717 | ||
1704 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1718 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1705 | itemIterator = mTodoMap.find(t); | 1719 | itemIterator = mTodoMap.find(t); |
1706 | if (itemIterator != mTodoMap.end()) { | 1720 | if (itemIterator != mTodoMap.end()) { |
1707 | (*itemIterator)->construct(); | 1721 | (*itemIterator)->construct(); |
1708 | } else { | 1722 | } else { |
1709 | if ( type == KOGlobals::EVENTADDED ) { | 1723 | if ( type == KOGlobals::EVENTADDED ) { |
1710 | insertTodoItem( t ); | 1724 | insertTodoItem( t ); |
1711 | } | 1725 | } |
1712 | } | 1726 | } |
1713 | 1727 | ||
1714 | } | 1728 | } |
1715 | 1729 | ||
1716 | void KOTodoView::todoModified(Todo * t , int p ) | 1730 | void KOTodoView::todoModified(Todo * t , int p ) |
1717 | { | 1731 | { |
1718 | mBlockUpdate = true; | 1732 | mBlockUpdate = true; |
1719 | emit todoModifiedSignal ( t, p ); | 1733 | emit todoModifiedSignal ( t, p ); |
1720 | mBlockUpdate = false; | 1734 | mBlockUpdate = false; |
1721 | } | 1735 | } |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index a8e90e2..9180015 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -129,97 +129,97 @@ class KOTodoListView : public KListView | |||
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 | */ |
136 | class KOQuickTodo : public QLineEdit | 136 | class 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 | */ |
152 | class KOTodoView : public KOrg::BaseView | 152 | class 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 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} | 175 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} |
176 | QString getWhatsThisText(QPoint p); | 176 | QString getWhatsThisText(QPoint p); |
177 | void clearList() {mTodoListView->clear(); } | 177 | void clearList( bool saveCurrentItem = true ); |
178 | 178 | ||
179 | public slots: | 179 | public slots: |
180 | void updateView(); | 180 | void updateView(); |
181 | void updateConfig(); | 181 | void updateConfig(); |
182 | 182 | ||
183 | void changeEventDisplay(Event *, int); | 183 | void changeEventDisplay(Event *, int); |
184 | 184 | ||
185 | void showDates(const QDate &start, const QDate &end); | 185 | void showDates(const QDate &start, const QDate &end); |
186 | void showEvents(QPtrList<Event> eventList); | 186 | void showEvents(QPtrList<Event> eventList); |
187 | 187 | ||
188 | void clearSelection(); | 188 | void clearSelection(); |
189 | void jumpToDate (); | 189 | void jumpToDate (); |
190 | 190 | ||
191 | void editItem(QListViewItem *item); | 191 | void editItem(QListViewItem *item); |
192 | void showItem(QListViewItem *item,const QPoint &,int); | 192 | void showItem(QListViewItem *item,const QPoint &,int); |
193 | void popupMenu(QListViewItem *item,const QPoint &,int); | 193 | void popupMenu(QListViewItem *item,const QPoint &,int); |
194 | void newTodo(); | 194 | void newTodo(); |
195 | void newSubTodo(); | 195 | void newSubTodo(); |
196 | void unparentTodo(); | 196 | void unparentTodo(); |
197 | void reparentTodo(); | 197 | void reparentTodo(); |
198 | void showTodo(); | 198 | void showTodo(); |
199 | void editTodo(); | 199 | void editTodo(); |
200 | void cloneTodo(); | 200 | void cloneTodo(); |
201 | void cancelTodo(); | 201 | void cancelTodo(); |
202 | void moveTodo(); | 202 | void moveTodo(); |
203 | void beamTodo(); | 203 | void beamTodo(); |
204 | void deleteTodo(); | 204 | void deleteTodo(); |
205 | 205 | ||
206 | void setNewPriority(int); | 206 | void setNewPriority(int); |
207 | void setNewPercentage(int); | 207 | void setNewPercentage(int); |
208 | void changedCategories(int); | 208 | void changedCategories(int); |
209 | 209 | ||
210 | void setAllOpen(); | 210 | void setAllOpen(); |
211 | void setAllClose(); | 211 | void setAllClose(); |
212 | void setAllFlat(); | 212 | void setAllFlat(); |
213 | void displayAllFlat(); | 213 | void displayAllFlat(); |
214 | 214 | ||
215 | void purgeCompleted(); | 215 | void purgeCompleted(); |
216 | void toggleCompleted(); | 216 | void toggleCompleted(); |
217 | void toggleRunning(); | 217 | void toggleRunning(); |
218 | void toggleQuickTodo(); | 218 | void toggleQuickTodo(); |
219 | void updateTodo( Todo *, int ); | 219 | void updateTodo( Todo *, int ); |
220 | 220 | ||
221 | void itemClicked(QListViewItem *); | 221 | void itemClicked(QListViewItem *); |
222 | void itemStateChanged(QListViewItem *); | 222 | void itemStateChanged(QListViewItem *); |
223 | void modified(bool); | 223 | void modified(bool); |
224 | void itemDoubleClicked(QListViewItem *item); | 224 | void itemDoubleClicked(QListViewItem *item); |
225 | void resetFocusToList(); | 225 | void resetFocusToList(); |