-rw-r--r-- | korganizer/kotodoview.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 395325c..935a5f5 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -731,6 +731,7 @@ void KOTodoView::storeCurrentItem() { mCurItem = 0; mCurItemRootParent = 0; + mCurItemParent = 0; mCurItemAbove = 0; mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); if (mActiveItem) { @@ -739,6 +740,7 @@ void KOTodoView::storeCurrentItem() if ( activeItemAbove ) mCurItemAbove = activeItemAbove->todo(); mCurItemRootParent = mCurItem; + mCurItemParent = mCurItemRootParent->relatedTo(); while ( mCurItemRootParent->relatedTo() != 0 ) mCurItemRootParent = mCurItemRootParent->relatedTo(); } @@ -750,6 +752,7 @@ void KOTodoView::resetCurrentItem() mTodoListView->setFocus(); KOTodoViewItem* foundItem = 0; KOTodoViewItem* foundItemRoot = 0; + KOTodoViewItem* foundItemParent = 0; KOTodoViewItem* foundItemAbove = 0; if ( mTodoListView->firstChild () ) { if ( mCurItem ) { @@ -761,18 +764,26 @@ void KOTodoView::resetCurrentItem() } else if ( item->todo() == mCurItemAbove ) { foundItemAbove = item; - } else if ( item->todo() == mCurItemRootParent ) { + } + if ( item->todo() == mCurItemRootParent ) { foundItemRoot = item; } + if ( item->todo() == mCurItemParent ) { + foundItemParent = item; + } item = (KOTodoViewItem*)item->itemBelow(); } if ( ! foundItem ) { + if ( foundItemParent ) { + foundItem = foundItemParent; + } else { if ( foundItemRoot ) foundItem = foundItemRoot; else foundItem = foundItemAbove; } } + } if ( foundItem ) { mTodoListView->setCurrentItem( foundItem ); mTodoListView->ensureItemVisible( foundItem ); |