-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 @@ -748,13 +748,12 @@ void KOTodoView::updateView() 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; @@ -835,7 +834,6 @@ void KOTodoView::updateView() if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); mTodoListView->blockSignals( false ); resetCurrentItem(); - processSelectionChange(); } void KOTodoView::storeCurrentItem() @@ -860,7 +858,7 @@ void KOTodoView::storeCurrentItem() void KOTodoView::resetCurrentItem() { - mTodoListView->setFocus(); + //mTodoListView->setFocus(); KOTodoViewItem* foundItem = 0; KOTodoViewItem* foundItemRoot = 0; KOTodoViewItem* foundItemParent = 0; @@ -896,12 +894,22 @@ 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; @@ -1404,6 +1412,7 @@ void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) void KOTodoView::displayAllFlat() { + storeCurrentItem(); pendingSubtodo = 0; if ( mBlockUpdate ) { return; @@ -1418,8 +1427,7 @@ void KOTodoView::displayAllFlat() KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); mTodoMap.insert(todo,todoItem); } - mTodoListView->setFocus(); - processSelectionChange(); + resetCurrentItem(); } void KOTodoView::setAllFlat() @@ -1430,9 +1438,7 @@ void KOTodoView::setAllFlat() 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 @@ -224,6 +224,7 @@ class KOTodoView : public KOrg::BaseView void itemStateChanged(QListViewItem *); void modified(bool); void itemDoubleClicked(QListViewItem *item); + void resetFocusToList(); signals: void newTodoSignal(); |