-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 a12c43e..d79a9b9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -468,97 +468,97 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | |||
468 | } | 468 | } |
469 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 469 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
470 | { | 470 | { |
471 | QListView::contentsMouseReleaseEvent(e); | 471 | QListView::contentsMouseReleaseEvent(e); |
472 | mMousePressed = false; | 472 | mMousePressed = false; |
473 | } | 473 | } |
474 | 474 | ||
475 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 475 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
476 | { | 476 | { |
477 | if (!e) return; | 477 | if (!e) return; |
478 | 478 | ||
479 | QPoint vp = contentsToViewport(e->pos()); | 479 | QPoint vp = contentsToViewport(e->pos()); |
480 | 480 | ||
481 | QListViewItem *item = itemAt(vp); | 481 | QListViewItem *item = itemAt(vp); |
482 | 482 | ||
483 | emit double_Clicked(item); | 483 | emit double_Clicked(item); |
484 | if (!item) return; | 484 | if (!item) return; |
485 | 485 | ||
486 | emit doubleClicked(item,vp,0); | 486 | emit doubleClicked(item,vp,0); |
487 | } | 487 | } |
488 | 488 | ||
489 | ///////////////////////////////////////////////////////////////////////////// | 489 | ///////////////////////////////////////////////////////////////////////////// |
490 | 490 | ||
491 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 491 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
492 | QLineEdit(parent) | 492 | QLineEdit(parent) |
493 | { | 493 | { |
494 | setText(i18n("Click to add new Todo")); | 494 | setText(i18n("Click to add new Todo")); |
495 | setFocusPolicy ( QWidget::ClickFocus ); | 495 | setFocusPolicy ( QWidget::ClickFocus ); |
496 | } | 496 | } |
497 | 497 | ||
498 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 498 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
499 | { | 499 | { |
500 | if ( text()==i18n("Click to add new Todo") ) | 500 | if ( text()==i18n("Click to add new Todo") ) |
501 | setText(""); | 501 | setText(""); |
502 | QLineEdit::focusInEvent(ev); | 502 | QLineEdit::focusInEvent(ev); |
503 | } | 503 | } |
504 | 504 | ||
505 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 505 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
506 | { | 506 | { |
507 | setText(i18n("Click to add new Todo")); | 507 | setText(i18n("Click to add new Todo")); |
508 | QLineEdit::focusOutEvent(ev); | 508 | QLineEdit::focusOutEvent(ev); |
509 | } | 509 | } |
510 | 510 | ||
511 | ///////////////////////////////////////////////////////////////////////////// | 511 | ///////////////////////////////////////////////////////////////////////////// |
512 | 512 | ||
513 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 513 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
514 | KOrg::BaseView(calendar,parent,name) | 514 | KOrg::BaseView(calendar,parent,name) |
515 | { | 515 | { |
516 | 516 | mIsActiveWindow = false; | |
517 | mCurItem = 0; | 517 | mCurItem = 0; |
518 | mCurItemRootParent = 0; | 518 | mCurItemRootParent = 0; |
519 | mCurItemParent = 0; | 519 | mCurItemParent = 0; |
520 | mCurItemAbove = 0; | 520 | mCurItemAbove = 0; |
521 | mActiveItem = 0; | 521 | mActiveItem = 0; |
522 | mCategoryPopupMenu = 0; | 522 | mCategoryPopupMenu = 0; |
523 | mPendingUpdateBeforeRepaint = false; | 523 | mPendingUpdateBeforeRepaint = false; |
524 | isFlatDisplay = false; | 524 | isFlatDisplay = false; |
525 | mNavigator = 0; | 525 | mNavigator = 0; |
526 | QBoxLayout *topLayout = new QVBoxLayout(this); | 526 | QBoxLayout *topLayout = new QVBoxLayout(this); |
527 | mName = QString ( name ); | 527 | mName = QString ( name ); |
528 | mBlockUpdate = false; | 528 | mBlockUpdate = false; |
529 | mQuickBar = new QWidget( this ); | 529 | mQuickBar = new QWidget( this ); |
530 | topLayout->addWidget(mQuickBar); | 530 | topLayout->addWidget(mQuickBar); |
531 | 531 | ||
532 | mQuickAdd = new KOQuickTodo(mQuickBar); | 532 | mQuickAdd = new KOQuickTodo(mQuickBar); |
533 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 533 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
534 | quickLayout->addWidget( mQuickAdd ); | 534 | quickLayout->addWidget( mQuickAdd ); |
535 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 535 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
536 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 536 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
537 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 537 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
538 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 538 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
539 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 539 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
540 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 540 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
541 | 541 | ||
542 | int fixwid = mQuickAdd->sizeHint().height(); | 542 | int fixwid = mQuickAdd->sizeHint().height(); |
543 | int fixhei = fixwid; | 543 | int fixhei = fixwid; |
544 | if ( QApplication::desktop()->width() > 800 ) | 544 | if ( QApplication::desktop()->width() > 800 ) |
545 | fixwid = (fixwid*3)/2; | 545 | fixwid = (fixwid*3)/2; |
546 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 546 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
547 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 547 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
548 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 548 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
549 | s_done->setPixmap( SmallIcon("greenhook16")); | 549 | s_done->setPixmap( SmallIcon("greenhook16")); |
550 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 550 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
551 | s_run->setPixmap( SmallIcon("ko16old")); | 551 | s_run->setPixmap( SmallIcon("ko16old")); |
552 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 552 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
553 | 553 | ||
554 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 554 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
555 | 555 | ||
556 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); | 556 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); |
557 | mNewSubBut->setEnabled( false ); | 557 | mNewSubBut->setEnabled( false ); |
558 | flat->setFixedWidth( fixwid ); | 558 | flat->setFixedWidth( fixwid ); |
559 | s_done->setFixedWidth( fixwid ); | 559 | s_done->setFixedWidth( fixwid ); |
560 | allopen->setFixedWidth( fixwid ); | 560 | allopen->setFixedWidth( fixwid ); |
561 | allclose->setFixedWidth( fixwid ); | 561 | allclose->setFixedWidth( fixwid ); |
562 | s_run->setFixedWidth( fixwid ); | 562 | s_run->setFixedWidth( fixwid ); |
563 | 563 | ||
564 | flat->setFixedHeight(fixhei ); | 564 | flat->setFixedHeight(fixhei ); |
@@ -905,165 +905,167 @@ void KOTodoView::updateView() | |||
905 | // specific order of events. That means that we have to generate parent items | 905 | // specific order of events. That means that we have to generate parent items |
906 | // recursively for proper hierarchical display of Todos. | 906 | // recursively for proper hierarchical display of Todos. |
907 | Todo *todo; | 907 | Todo *todo; |
908 | todo = todoList.first();// todo; todo = todoList.next()) { | 908 | todo = todoList.first();// todo; todo = todoList.next()) { |
909 | while ( todo ) { | 909 | while ( todo ) { |
910 | bool next = true; | 910 | bool next = true; |
911 | // qDebug("todo %s ", todo->summary().latin1()); | 911 | // qDebug("todo %s ", todo->summary().latin1()); |
912 | Incidence *incidence = todo->relatedTo(); | 912 | Incidence *incidence = todo->relatedTo(); |
913 | while ( incidence ) { | 913 | while ( incidence ) { |
914 | if ( incidence->typeID() == todoID ) { | 914 | if ( incidence->typeID() == todoID ) { |
915 | //qDebug("related %s ",incidence->summary().latin1() ); | 915 | //qDebug("related %s ",incidence->summary().latin1() ); |
916 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 916 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
917 | //qDebug("related not found "); | 917 | //qDebug("related not found "); |
918 | todoList.remove( ); | 918 | todoList.remove( ); |
919 | todo = todoList.current(); | 919 | todo = todoList.current(); |
920 | next = false; | 920 | next = false; |
921 | incidence = 0; | 921 | incidence = 0; |
922 | 922 | ||
923 | } else { | 923 | } else { |
924 | //qDebug("related found "); | 924 | //qDebug("related found "); |
925 | incidence = incidence->relatedTo(); | 925 | incidence = incidence->relatedTo(); |
926 | } | 926 | } |
927 | } else | 927 | } else |
928 | incidence = 0; | 928 | incidence = 0; |
929 | } | 929 | } |
930 | if ( next ) | 930 | if ( next ) |
931 | todo = todoList.next(); | 931 | todo = todoList.next(); |
932 | } | 932 | } |
933 | 933 | ||
934 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 934 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
935 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 935 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
936 | { | 936 | { |
937 | insertTodoItem(todo); | 937 | insertTodoItem(todo); |
938 | } | 938 | } |
939 | } | 939 | } |
940 | // Restore opened/closed state | 940 | // Restore opened/closed state |
941 | mTodoListView->blockSignals( true ); | 941 | mTodoListView->blockSignals( true ); |
942 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 942 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
943 | mTodoListView->blockSignals( false ); | 943 | mTodoListView->blockSignals( false ); |
944 | resetCurrentItem(); | 944 | resetCurrentItem(); |
945 | } | 945 | } |
946 | 946 | ||
947 | void KOTodoView::storeCurrentItem() | 947 | void KOTodoView::storeCurrentItem() |
948 | { | 948 | { |
949 | mCurItem = 0; | 949 | mCurItem = 0; |
950 | mCurItemRootParent = 0; | 950 | mCurItemRootParent = 0; |
951 | mCurItemParent = 0; | 951 | mCurItemParent = 0; |
952 | mCurItemAbove = 0; | 952 | mCurItemAbove = 0; |
953 | mIsActiveWindow = topLevelWidget()->isActiveWindow(); | ||
953 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 954 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
954 | if (mActiveItem) { | 955 | if (mActiveItem) { |
955 | mCurItem = mActiveItem->todo(); | 956 | mCurItem = mActiveItem->todo(); |
956 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 957 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
957 | if ( activeItemAbove ) | 958 | if ( activeItemAbove ) |
958 | mCurItemAbove = activeItemAbove->todo(); | 959 | mCurItemAbove = activeItemAbove->todo(); |
959 | mCurItemRootParent = mCurItem; | 960 | mCurItemRootParent = mCurItem; |
960 | mCurItemParent = mCurItemRootParent->relatedTo(); | 961 | mCurItemParent = mCurItemRootParent->relatedTo(); |
961 | while ( mCurItemRootParent->relatedTo() != 0 ) | 962 | while ( mCurItemRootParent->relatedTo() != 0 ) |
962 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 963 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
963 | } | 964 | } |
964 | mActiveItem = 0; | 965 | mActiveItem = 0; |
965 | } | 966 | } |
966 | 967 | ||
967 | void KOTodoView::resetCurrentItem() | 968 | void KOTodoView::resetCurrentItem() |
968 | { | 969 | { |
969 | //mTodoListView->setFocus(); | 970 | //mTodoListView->setFocus(); |
970 | KOTodoViewItem* foundItem = 0; | 971 | KOTodoViewItem* foundItem = 0; |
971 | KOTodoViewItem* foundItemRoot = 0; | 972 | KOTodoViewItem* foundItemRoot = 0; |
972 | KOTodoViewItem* foundItemParent = 0; | 973 | KOTodoViewItem* foundItemParent = 0; |
973 | KOTodoViewItem* foundItemAbove = 0; | 974 | KOTodoViewItem* foundItemAbove = 0; |
974 | if ( mTodoListView->firstChild () ) { | 975 | if ( mTodoListView->firstChild () ) { |
975 | if ( mCurItem ) { | 976 | if ( mCurItem ) { |
976 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 977 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
977 | while ( item ) { | 978 | while ( item ) { |
978 | if ( item->todo() == mCurItem ) { | 979 | if ( item->todo() == mCurItem ) { |
979 | foundItem = item; | 980 | foundItem = item; |
980 | break; | 981 | break; |
981 | } else if ( item->todo() == mCurItemAbove ) { | 982 | } else if ( item->todo() == mCurItemAbove ) { |
982 | foundItemAbove = item; | 983 | foundItemAbove = item; |
983 | 984 | ||
984 | } | 985 | } |
985 | if ( item->todo() == mCurItemRootParent ) { | 986 | if ( item->todo() == mCurItemRootParent ) { |
986 | foundItemRoot = item; | 987 | foundItemRoot = item; |
987 | } | 988 | } |
988 | if ( item->todo() == mCurItemParent ) { | 989 | if ( item->todo() == mCurItemParent ) { |
989 | foundItemParent = item; | 990 | foundItemParent = item; |
990 | } | 991 | } |
991 | item = (KOTodoViewItem*)item->itemBelow(); | 992 | item = (KOTodoViewItem*)item->itemBelow(); |
992 | } | 993 | } |
993 | if ( ! foundItem ) { | 994 | if ( ! foundItem ) { |
994 | if ( foundItemParent ) { | 995 | if ( foundItemParent ) { |
995 | foundItem = foundItemParent; | 996 | foundItem = foundItemParent; |
996 | } else { | 997 | } else { |
997 | if ( foundItemRoot ) | 998 | if ( foundItemRoot ) |
998 | foundItem = foundItemRoot; | 999 | foundItem = foundItemRoot; |
999 | else | 1000 | else |
1000 | foundItem = foundItemAbove; | 1001 | foundItem = foundItemAbove; |
1001 | } | 1002 | } |
1002 | } | 1003 | } |
1003 | } | 1004 | } |
1004 | if ( foundItem ) { | 1005 | if ( foundItem ) { |
1005 | mTodoListView->setSelected ( foundItem, true ); | 1006 | mTodoListView->setSelected ( foundItem, true ); |
1006 | mTodoListView->setCurrentItem( foundItem ); | 1007 | mTodoListView->setCurrentItem( foundItem ); |
1007 | mTodoListView->ensureItemVisible( foundItem ); | 1008 | mTodoListView->ensureItemVisible( foundItem ); |
1008 | } else { | 1009 | } else { |
1009 | if ( mTodoListView->firstChild () ) { | 1010 | if ( mTodoListView->firstChild () ) { |
1010 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 1011 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
1011 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 1012 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
1012 | } | 1013 | } |
1013 | } | 1014 | } |
1014 | } | 1015 | } |
1015 | processSelectionChange(); | 1016 | processSelectionChange(); |
1016 | if ( mName != "todolistsmall" ) | 1017 | if ( mName != "todolistsmall" ) |
1017 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 1018 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
1018 | } | 1019 | } |
1019 | void KOTodoView::resetFocusToList() | 1020 | void KOTodoView::resetFocusToList() |
1020 | { | 1021 | { |
1021 | topLevelWidget()->setActiveWindow(); | 1022 | if ( mIsActiveWindow ) |
1023 | topLevelWidget()->setActiveWindow(); | ||
1022 | mTodoListView->setFocus(); | 1024 | mTodoListView->setFocus(); |
1023 | } | 1025 | } |
1024 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 1026 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
1025 | bool KOTodoView::checkTodo( Todo * todo ) | 1027 | bool KOTodoView::checkTodo( Todo * todo ) |
1026 | { | 1028 | { |
1027 | 1029 | ||
1028 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 1030 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
1029 | return false; | 1031 | return false; |
1030 | if ( !todo->isCompleted() ) { | 1032 | if ( !todo->isCompleted() ) { |
1031 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 1033 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
1032 | return true; | 1034 | return true; |
1033 | } | 1035 | } |
1034 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 1036 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
1035 | if ( todo->hasStartDate() ) | 1037 | if ( todo->hasStartDate() ) |
1036 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 1038 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
1037 | return false; | 1039 | return false; |
1038 | if ( todo->hasDueDate() ) | 1040 | if ( todo->hasDueDate() ) |
1039 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 1041 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
1040 | return false; | 1042 | return false; |
1041 | } | 1043 | } |
1042 | return true; | 1044 | return true; |
1043 | } | 1045 | } |
1044 | 1046 | ||
1045 | void KOTodoView::restoreItemState( QListViewItem *item ) | 1047 | void KOTodoView::restoreItemState( QListViewItem *item ) |
1046 | { | 1048 | { |
1047 | pendingSubtodo = 0; | 1049 | pendingSubtodo = 0; |
1048 | while( item ) { | 1050 | while( item ) { |
1049 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1051 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1050 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 1052 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
1051 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 1053 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
1052 | item = item->nextSibling(); | 1054 | item = item->nextSibling(); |
1053 | } | 1055 | } |
1054 | } | 1056 | } |
1055 | 1057 | ||
1056 | 1058 | ||
1057 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1059 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
1058 | KOTodoView::insertTodoItem(Todo *todo) | 1060 | KOTodoView::insertTodoItem(Todo *todo) |
1059 | { | 1061 | { |
1060 | 1062 | ||
1061 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1063 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1062 | // TODO: Check, if dynmaic cast is necessary | 1064 | // TODO: Check, if dynmaic cast is necessary |
1063 | 1065 | ||
1064 | pendingSubtodo = 0; | 1066 | pendingSubtodo = 0; |
1065 | Incidence *incidence = todo->relatedTo(); | 1067 | Incidence *incidence = todo->relatedTo(); |
1066 | while ( incidence && !incidence->calEnabled() ) | 1068 | while ( incidence && !incidence->calEnabled() ) |
1067 | incidence = incidence->relatedTo(); | 1069 | incidence = incidence->relatedTo(); |
1068 | if (incidence && incidence->typeID() == todoID ) { | 1070 | if (incidence && incidence->typeID() == todoID ) { |
1069 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1071 | Todo *relatedTodo = static_cast<Todo *>(incidence); |