-rw-r--r-- | korganizer/kotodoview.cpp | 22 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 |
2 files changed, 15 insertions, 8 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8d354c8..e2966f8 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -747,15 +747,14 @@ void KOTodoView::updateView() if ( !isVisible() ) { mPendingUpdateBeforeRepaint = true; return; } - storeCurrentItem(); //qDebug("KOTodoView::updateView() %x", this); if ( isFlatDisplay ) { displayAllFlat(); - resetCurrentItem(); return; } + storeCurrentItem(); //qDebug("update "); // kdDebug() << "KOTodoView::updateView()" << endl; QFont fo = KOPrefs::instance()->mTodoViewFont; @@ -834,9 +833,8 @@ void KOTodoView::updateView() mTodoListView->blockSignals( true ); if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); mTodoListView->blockSignals( false ); resetCurrentItem(); - processSelectionChange(); } void KOTodoView::storeCurrentItem() { @@ -859,9 +857,9 @@ void KOTodoView::storeCurrentItem() } void KOTodoView::resetCurrentItem() { - mTodoListView->setFocus(); + //mTodoListView->setFocus(); KOTodoViewItem* foundItem = 0; KOTodoViewItem* foundItemRoot = 0; KOTodoViewItem* foundItemParent = 0; KOTodoViewItem* foundItemAbove = 0; @@ -895,14 +893,24 @@ void KOTodoView::resetCurrentItem() } } } if ( foundItem ) { + mTodoListView->setSelected ( foundItem, true ); mTodoListView->setCurrentItem( foundItem ); mTodoListView->ensureItemVisible( foundItem ); } else { + if ( mTodoListView->firstChild () ) { + mTodoListView->setSelected ( mTodoListView->firstChild (), true ); mTodoListView->setCurrentItem( mTodoListView->firstChild () ); } } + } + processSelectionChange(); + QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); +} +void KOTodoView::resetFocusToList() +{ + topLevelWidget()->setActiveWindow(); mTodoListView->setFocus(); } //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; bool KOTodoView::checkTodo( Todo * todo ) @@ -1403,8 +1411,9 @@ void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) } void KOTodoView::displayAllFlat() { + storeCurrentItem(); pendingSubtodo = 0; if ( mBlockUpdate ) { return; } @@ -1417,10 +1426,9 @@ void KOTodoView::displayAllFlat() for(todo = todoList.first(); todo; todo = todoList.next()) { KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); mTodoMap.insert(todo,todoItem); } - mTodoListView->setFocus(); - processSelectionChange(); + resetCurrentItem(); } void KOTodoView::setAllFlat() { @@ -1429,11 +1437,9 @@ void KOTodoView::setAllFlat() mPopupMenu->setItemChecked( 8,false ); updateView(); return; } - storeCurrentItem(); displayAllFlat(); - resetCurrentItem(); } void KOTodoView::purgeCompleted() { diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 1b31d0d..9ae7f53 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -223,8 +223,9 @@ class KOTodoView : public KOrg::BaseView void itemClicked(QListViewItem *); void itemStateChanged(QListViewItem *); void modified(bool); void itemDoubleClicked(QListViewItem *item); + void resetFocusToList(); signals: void newTodoSignal(); void newSubTodoSignal(Todo *); |