-rw-r--r-- | korganizer/kotodoview.cpp | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index e008625..ccc4b01 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -266,5 +266,20 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | |||
266 | } | 266 | } |
267 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 267 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
268 | { | 268 | { |
269 | if ( !e->isAutoRepeat() ) { | ||
270 | mFlagKeyPressed = false; | ||
271 | } | ||
272 | } | ||
273 | |||
269 | 274 | ||
275 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | ||
276 | { | ||
277 | qApp->processEvents(); | ||
278 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
279 | e->ignore(); | ||
280 | // qDebug(" ignore %d",e->isAutoRepeat() ); | ||
281 | return; | ||
282 | } | ||
283 | if (! e->isAutoRepeat() ) | ||
284 | mFlagKeyPressed = true; | ||
270 | QListViewItem* cn; | 285 | QListViewItem* cn; |
@@ -291,3 +306,2 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | |||
291 | 306 | ||
292 | // qDebug("KOTodoListView::keyPressEvent "); | ||
293 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 307 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
@@ -600,2 +614,3 @@ void KOTodoView::updateView() | |||
600 | } | 614 | } |
615 | storeCurrentItem(); | ||
601 | //qDebug("KOTodoView::updateView() %x", this); | 616 | //qDebug("KOTodoView::updateView() %x", this); |
@@ -603,2 +618,3 @@ void KOTodoView::updateView() | |||
603 | displayAllFlat(); | 618 | displayAllFlat(); |
619 | resetCurrentItem(); | ||
604 | return; | 620 | return; |
@@ -608,6 +624,3 @@ void KOTodoView::updateView() | |||
608 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 624 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
609 | Incidence* oldInc = 0; | 625 | |
610 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
611 | if (mActiveItem) | ||
612 | oldInc = mActiveItem->todo(); | ||
613 | 626 | ||
@@ -693,11 +706,42 @@ void KOTodoView::updateView() | |||
693 | mTodoListView->blockSignals( false ); | 706 | mTodoListView->blockSignals( false ); |
707 | resetCurrentItem(); | ||
708 | processSelectionChange(); | ||
709 | } | ||
710 | |||
711 | void KOTodoView::storeCurrentItem() | ||
712 | { | ||
713 | mCurItem = 0; | ||
714 | mCurItemRootParent = 0; | ||
715 | mCurItemAbove = 0; | ||
716 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
717 | if (mActiveItem) { | ||
718 | mCurItem = mActiveItem->todo(); | ||
719 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | ||
720 | if ( activeItemAbove ) | ||
721 | mCurItemAbove = activeItemAbove->todo(); | ||
722 | while ( mActiveItem->parent() != 0 ) | ||
723 | mActiveItem = (KOTodoViewItem*)mActiveItem->parent(); | ||
724 | mCurItemRootParent = mActiveItem->todo(); | ||
725 | } | ||
726 | mActiveItem = 0; | ||
727 | } | ||
728 | |||
729 | void KOTodoView::resetCurrentItem() | ||
730 | { | ||
694 | mTodoListView->setFocus(); | 731 | mTodoListView->setFocus(); |
732 | KOTodoViewItem* foundItem = 0; | ||
733 | KOTodoViewItem* foundItemRoot = 0; | ||
734 | KOTodoViewItem* foundItemAbove = 0; | ||
695 | if ( mTodoListView->firstChild () ) { | 735 | if ( mTodoListView->firstChild () ) { |
696 | if ( oldInc ) { | 736 | if ( mCurItem ) { |
697 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 737 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
698 | while ( item ) { | 738 | while ( item ) { |
699 | if ( item->todo() == oldInc ) { | 739 | if ( item->todo() == mCurItem ) { |
700 | mTodoListView->setCurrentItem( item ); | 740 | foundItem = item; |
701 | mTodoListView->ensureItemVisible( item ); | ||
702 | break; | 741 | break; |
742 | } else if ( item->todo() == mCurItemAbove ) { | ||
743 | foundItemAbove = item; | ||
744 | |||
745 | } else if ( item->todo() == mCurItemRootParent ) { | ||
746 | foundItemRoot = item; | ||
703 | } | 747 | } |
@@ -705,4 +749,12 @@ void KOTodoView::updateView() | |||
705 | } | 749 | } |
706 | if ( ! item ) | 750 | if ( ! foundItem ) { |
707 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 751 | if ( foundItemAbove ) |
752 | foundItem = foundItemAbove; | ||
753 | else | ||
754 | foundItem = foundItemRoot; | ||
755 | } | ||
756 | } | ||
757 | if ( foundItem ) { | ||
758 | mTodoListView->setCurrentItem( foundItem ); | ||
759 | mTodoListView->ensureItemVisible( foundItem ); | ||
708 | } else { | 760 | } else { |
@@ -711,5 +763,5 @@ void KOTodoView::updateView() | |||
711 | } | 763 | } |
712 | processSelectionChange(); | 764 | mTodoListView->setFocus(); |
713 | } | 765 | } |
714 | 766 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | |
715 | bool KOTodoView::checkTodo( Todo * todo ) | 767 | bool KOTodoView::checkTodo( Todo * todo ) |
@@ -1241,2 +1293,3 @@ void KOTodoView::addQuickTodo() | |||
1241 | } | 1293 | } |
1294 | |||
1242 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1295 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |